Tkinter: make a 'disabled' widget look even more 'disabled' - python

I have this collection of Listboxes (see image). The 2nd and 3rd Listboxes are disabled by default until the user adds an item to the 1st Listbox and selects it, at which point the two other Listboxes can be edited.
Image here
The problem i have is that the 'disabled' state of this Listboxes look too much as a 'normal' one, and im worried it might not be intuitive enough for the user that he must work on the first Listbox first.
Is there a way to make the disabled state of a widget look even more disabled?
I was thinking, maybe change the color of the widget to something more darker... but i'm not a graphic designer so i really have no clue.
Is it even possible to change the appearence of disabled widgets in the first place?
Thanks in advance

Related

How to place a panedWindow behind another panedWindow tkinter

The title basically says it. Right now I have the two panedWindows attached to the root window. I would like the windows to either lift() or lower() one panedWindow on top of the other when a button is pressed rather than the panedWindows being stacked on top of each other in the same window.
I also understand there may be a better way of implementing this sort of menu feature. If you know a better way, that would be great too.
I used .grid(row = 0) on both panedWindows. Then I called lift on the window I wanted to raise up and it worked.

wxpython Event order

I have a wxPython gui with a grid. When a user clicks on certain cells, a drop-down menu will pop up.
self.window.Bind(wx.grid.EVT_GRID_SELECT_CELL, lambda event: self.on_left_click(event, self.grid, choices), self.grid)
The method on_left_click pulls up the drop-down menu and works as expected. The problem is that I want the default behavior for wx.grid.EVT_GRID_SELECT_CELL to happen first, and then for my custom method to fire. Normally, when you click on a grid cell, that cell's border gets bold. With my binding, the my drop-down menu appears first, and only once the drop-down menu is dismissed does the cell border get selected. I tried calling self.grid.SetGridCursor(row, col), but that generates a wx.grid.EVT_GRID_SELECT_CELL event, which causes a recursion max out and obviously is no good. I also tried using event.Skip() in the on_left_click code, but it doesn't seem to have an effect.
Here is the awkward, objectionable behavior (I just clicked on row 0, col 2):
Here is the desired behavior:
I am happy to provide more of the code if needed. I would like to do one of the following. One, somehow force wxPython to fully process wx.grid.EVT_GRID_SELECT_CELL before moving on to my custom drop-down menu. Two, manually duplicate the effect of "highlighting" the selected cell in my own code.
Thanks in advance for any help.
edit:
Here's what I ended up doing.
In place of wx.grid.EVT_GRID_SELECT_CELL, I used wx.grid.EVT_GRID_CELL_LEFT_CLICK which is essentially the first event to be fired when a user clicks on a grid cell, so I could fully customize the behavior following that initial click. Then, I could use this:
self.grid.SetGridCursor(row, col)
to outline the cell without creating the infinite recursion error, as well as implementing a bunch of other behavior that is now working more smoothly. I also needed to use self.grid.Refresh().
Create a separate method for showing drop down menu and call it with wx.CallAfter.
def on_left_click(self, event, grid, choices):
event.Skip()
self.grid.Refresh()
wx.CallAfter(self.showMenu, grid=grid, choices=choices)
def showMenu(self, grid=None, choices=None):
# Drop down menu code goes here

Clear Window in Tkinter

I have a tkinter GUI that, when opened, is an empty widget with a menu bar on top. Clicking on the options on the menu causes for text boxes, more buttons and more menus to appear in the widget. My problem is that everything overlaps.
I need an easy way to delete everything that is currently there, like a "clear window" option.
I've tried packing everything into a frame and then destroying a frame but, for some reason, it's not working.
Any suggestions?
Ideally, I would make something that checks to see if there is anything (button, text box, menu) in a designated space, and it would delete it all before creating the new widget attributes.
The Problem I was having was fixed by creating a new frame within each function and having the code destroy any previously existing frames with Frame.destroy().
My second problem, where widgets within my frame were not, appearing was being caused by how Tkinter frames automatically resize to fit the original widgets. Therefore, when I added widgets to the frame, the frame remained the size of the first widget and didn't show the new buttons. I used frame.pack_propagate(0) to force the frame to remain the specified size.

Python: Creating own Widget with scrollbars

I'm working on a X-plotter like widget that plots incomming data live.
I already searched for an solution to realize a scrolling along the x-axis if the widget has to much values and so they don't fit.
I had the folling approaches to realize it:
derive from a widget that supports scrolling and child widgets and add my own widget while making it bigger and bigger during the live updates: -> Which parent do I need to use and how do I avoid to draw all the stuff that is currently not visible?
modify my widget in a way that it supports the scrollbars itself -> but how?
draw/handle my own scrollbars -> worstcase :(
I really searched the web for suggestions or examples, but there is nothing about how to "construct" custom controls in a good way (beyond drawing something) esp. in the case of interaction...
Sorry but I'm a newbie at GTK in general :/
Most widgets in Gtk do not have scrollbars.
If you want to scroll the entire widget, you have to implement the GtkScrollable interface. Then, you add the widget to a GtkScrolledWindow. The scrolled window has the scrollbars, those GtkScrollbars are linked with GtkAdjustments which are passed to your custom widget through the GtkScrollable interface set_vadjustment and set_hadjustment.
If you just want to add a scrollbar and control its behaviour yourself, then you need to somehow add a GtkScrollbar in your widget, which means you will need to make it a container too.
The GtkScrollable approach is the following, first you implement vadjustment and hadjustment setters and getters, then when the GtkAdjustments are set, you set its lower and upper limits and the page size(how much of the widget is visible at once). After that, you connect their value-changed signal so you can refresh your widget when the scrollbars are dragged. A GtkScrollable doesn't get to check the scrollbars, only the adjustments that will be bound to the scrollbars. When drawing the widget you get the adjustments' value property in order to determine how much the scrollbars have shifted in the horizontal and vertical axes.

Horizontally oriented listbox using Python and Tkinter

I want to provide a listbox where the user can select (multiple) characters (usually close to 15). Quite often some of these will be sequenced, so a listbox is easier than a validated text entry field.
Since the character combination has a meaning to the user, it is user friendly to orient the listbox horizontally.
Is there an easy way e.g. a theme, setting or subclass of the Tkinter listbox so I do not have to build my own?
No, there is no setting, subclass or theme that will let you do that with a listbox.
What you might want to use instead is a set of check buttons with the indicator turned off so they each appear as a button with a single letter. You can then pack them all horizontally in a frame. With the indicator off, the button will appear sunken when selected, or normal otherwise.

Categories