I have two questions regarding Tkinter GUIs:

  1. I have three buttons in a GUI; at times it seems that the buttons "stick". By this I mean when the mouse is clicked on one it may activate or it may not. They all work correctly in regards to there function(s) but it sometimes takes 2-3 clicks to actually get it to fully respond; I figure that this may have to do with my system, memory resources, or something of that nature. The way in which they tend to not resond sometimes is completely random it seems. Has anyone had this issue before and if so, is their a technique to fix this via code optimization?
  2. Is there a way to change the color\theme of the border of a frame such as the silver border in the GUI pictured below? This is just a small detail but I would like to be able to have this choice if possible for graphic design reasons. I believe I have read that the color\theme of such a GUI element is system dependent, in this case, Windows XP (the same silver color\theme as my system) Is this indeed true that Tkinter does not allow adjustment of said GUI elements?

[IMG]http://i52.photobucket.com/albums/g31/reranger/untitled.jpg[/IMG]

Thank-you in advance for any help\direction offered,
Matty

Dani AI

Generated

Quick, practical summary for both points (ties to the replies from , and ): intermittent “sticky” buttons often end up being hardware (mouse) or input-event problems, but can also come from the Tk mainloop being blocked by long-running work or from mixing another event loop (e.g. pygame). was correct that the OS/window-manager draws the outer window chrome, so the silver titlebar/border seen in the screenshot can’t be changed from Tkinter — however the inner widget borders can be styled.

Troubleshooting checklist (in order of least effort to most):

  • Verify hardware first: try a different mouse, try the same mouse on another machine, or swap batteries (as reported solving the issue).

  • Add a simple event probe to confirm whether clicks reach the widget (bind a <Button-1> and log the event). For example:

    def probe(ev):
        print("clicked:", ev.widget)
    button.bind("<Button-1>", probe)
  • Check for UI blocking: any heavy computation on the main thread will make clicks seem unresponsive. Break work into small chunks with root.after(...) or move it to a worker thread and post results back to the GUI thread via a queue.

  • Look for grabs/focus changes or accidental use of grab_set() which can divert events. If pygame or another library is in use, run it separately or avoid running two event loops in the same thread.

Border/appearance options inside the window: standard Tk widgets support bd, relief, highlightthickness, highlightbackground and background. Example:

frame = Frame(root, bd=2, relief="solid",
              highlightthickness=2, highlightbackground="red")

ttk widgets use themes; use ttk.Style().configure("Name.TFrame", background="#DDD") to style a TFrame. To change the actual window chrome requires overrideredirect(True) and a custom titlebar (more work and platform-specific).

Recommended Answers

All 4 Replies

Hi!

Ad 1: Show some code ;)

Ad 2: Tkinter isn't responsible for the window decorations, but your window-manager is. So, no, it is not possilbe to change them from Tkinter.

Regards, mawe

Unless you have a huge amount of events in your loop, it could very well be your mouse.

commented: Tkiner GUI #Always helpful ;) mattyd +3

Hi mattyd,

Does that image represent a pygame game wrapped inside a Tkinter widget? Is that what you're trying to do?

Running pygame and Tkinter together can be tricky, as both open new threads that listen for user input, and threading bugs are always the hardest to squash. Without seeing the code, I can't tell you exactly what's wrong; my suggestion would be to try decoupling the pygame module from the Tkinter module and see if the problem persists (in other words, comment out the entire game loop and pygame initialization code, put `print "FLAG"; return` commands in the beginning of each button function, and see if "stickiness" is still an issue). Of course, if you're not mixing pygame and Tkinter please say so and I will reconsider the problem.

Hope that helps.

commented: tkinter GUI| #thanks for your help ;) mattyd +3

Unless you have a huge amount of events in your loop, it could very well be your mouse.

Not a lot of events. Think it could be the optical mouse. Changed batteries-- works much better.

Thanks, Ene
MattyD

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.