widget

python tkinter packing

大憨熊 提交于 2021-01-29 03:50:20
问题 Could someone please explain why when you have an plain widget as one line Code A works Entry(root, width=10).pack(side=LEFT,anchor=W) but when you name it or attach a command to it, Code A no longer works and gives you Error Message B self.my_entry = Entry(root, width=10).pack(side=LEFT,anchor=W) and you must pack using a seperate line? self.my_entry = Entry(root, width=10) self.my_entry.pack(side=LEFT,anchor=W) Code A self.my_entry.get() Error Message B AttributeError: 'NoneType' object has

Ideal way to config all the buttons of my Tkinter application at once?

与世无争的帅哥 提交于 2021-01-28 10:51:40
问题 This is my first tkinter/gui project. I set up a mvc pattern and have a view class for each window of my application. An example for the main window: class ViewMain(tk.Frame): def __init__(self, master): tk.Frame.__init__(self, master, height = 300, width = 500) self.pack(fill='both', expand=True) self.BUTTON_SIZE = {'relheight' : 0.3, 'relwidth' : 0.35} self._set_widgets() self._set_layout() def _set_widgets(self): self.button = tk.Button(self, text = 'Text') def _set_layout(self): self

How to tell `ipywidgets.interactive`, that it should consider only specific parameters as widgets?

99封情书 提交于 2021-01-28 09:19:03
问题 It seems like ipywidgets.interactive tries to make every imput after the function to be a widget. In the following example, I get two widgets, one for age and one for name : import ipywidgets def greetings(age, name='John'): print(f'{name} is {age} years old') ipywidgets.interactive(greetings, age = widgets.IntSlider(), name = "Bob") My expectation was, that I only get one widget for age , since it is of type ipywidgets.widgets.widget_int.IntSlider whereas "Bob" is of type str (where I don't

Hide subcategories from woocommerce category widget

Deadly 提交于 2021-01-28 06:21:51
问题 I'm using the built-in woocommerce category widget, and at the moment it's displaying both the categories and subcategories. I excluded a category via this code: add_filter( 'woocommerce_product_categories_widget_args', 'organicweb_exclude_widget_category' ); function organicweb_exclude_widget_category( $args ) { // Enter the id of the category you want to exclude in place of '30' $args['exclude'] = array('62' ); return $args; } but the widget still shows it's subcategories. link: http:/

How to insert a scrollbar to a menu?

女生的网名这么多〃 提交于 2021-01-28 06:04:59
问题 I want to add another widget, in this case a scale widget, to a menu widget in tkinter. Right now the only solutions I see are creating a new command and open a new window with the scale widget or creating the scale widget elsewhere. Both don't seem too appealing to me. Any ideas how to archive this are welcome :) 回答1: You cant add a scrollbar to it, but I have coded something similar to this. Its a hacky way and maybe its hard to understand but I can try to explain. Note as Bryan mentioned

How to insert a scrollbar to a menu?

限于喜欢 提交于 2021-01-28 05:56:16
问题 I want to add another widget, in this case a scale widget, to a menu widget in tkinter. Right now the only solutions I see are creating a new command and open a new window with the scale widget or creating the scale widget elsewhere. Both don't seem too appealing to me. Any ideas how to archive this are welcome :) 回答1: You cant add a scrollbar to it, but I have coded something similar to this. Its a hacky way and maybe its hard to understand but I can try to explain. Note as Bryan mentioned

tkinter - Change color of a disabled entry widget

眉间皱痕 提交于 2021-01-27 21:50:32
问题 Is there a way that I could change a color of disabled entry widget in python? x = tk.Entry(parent) x.configure({"background": "gray24"}) x.configure({"fg": "white"}) x.configure({"state": "disable"}) The code above only works when the "state" of the widget is "normal". 回答1: Set the entry widget's disabledbackground attribute. x.configure({"disabledbackground": "newcolour"}) Where "newcolour" is the colour you want to see when the entry widget is disabled. You can also use disabledforeground

How to set kivy widget id from Python code file

孤街醉人 提交于 2021-01-27 18:47:41
问题 I need help assigning ids to new kivy widgets that are created from a python function I've tried : old = Label(id = 'old') and : old = Label() old.id = 'old' but it doesn't seem to work because, whenever i try referencing the widgets, it gives me an error 回答1: The ways that you have creating id in Python code are correct. But you cannot reference them using self.ids.old or self.ids['old'] because they don't exist in self.ids . The self.ids dictionary type property contains only all widgets

How to position an independent Window in an exact location on the screen?

感情迁移 提交于 2021-01-27 14:10:33
问题 I'm actually working on a relatively complex GTK+2 application. My application obviously have a main window; then I need to open a new "independent" Window. I need to place the "flying" window in a * precise position* of the screen, exactly at the vertices of a widget (a DrawingArea). I need to place the new window in a precise position of the screen, exactly at the vertices of a widget (a gtk.DrawingArea). So I thought the following algorithm: I get vertex coordinates of the DrawingArea

Adding widgets to Qt Designer

核能气质少年 提交于 2021-01-27 14:07:55
问题 I have recently discovered that Qt supports custom widgets, and that there are sites that provide this kind of widgets ( like Qt-Apps ). If it is relevant, I am interested in getting this widget. I have downloaded the source code for it, I have extracted it etc. I haven't tried to build it yet, but what I am interested in is having that widget in the widget list in the left side of the Qt Designer so that I can use it my applications. I either don't know how to search what I am looking for,