在Python中使用OptionMenu [英] Use OptionMenu in Python

查看:63
本文介绍了在Python中使用OptionMenu的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

self.btype2=StringVar()
self.cboType = OptionMenu(self.master,self.btype2,"Computer","Science","General")
self.cboType.place(x=15, y=20, width=150, height=23)
self.cboType.config(state='normal')
self.btype2=self.cboType

这是我们用于选项菜单的代码,现在的问题是我们如何分配值并将其添加到数据库中?预先感谢您的回答

that is our code for option menu, our problem now is that how can we assign values and add it on database? thank you in advance for you answers

推荐答案

使用btype2,因为这是您的字符串变量.您不需要self.btype2 = self.cboType.如果要从中选择的三个项目是要转到Db的内容,则在Db语句中使用btype2,将其放置在其中.IE.

Use btype2 as that is your string variable. You do not need the self.btype2=self.cboType. If the three items to select from are what you want to go to the Db then in your Db statement use btype2 where you would put what it is. I.E.

插入表名值(btype2)

insert into tablename Values(btype2)

这篇关于在Python中使用OptionMenu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆