Python Forum
Multi windows in tkinter buttons not responding correctly
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multi windows in tkinter buttons not responding correctly
#10
toggleButton1 only exists in the MainFloor class.  You're trying to change it from within the Fireplace class.  A nice way to handle this would be using events or signals (something frequently done in game programming, and is how something like the physics code will do most of it's communication).  But that'd be a whole lot of changes.

You currently pass each object a controller object, but the Fireplace doesn't keep track of it.  If you do, then you can crawl into the controller and manipulate it's frames to get to the MainFloor to do what you're trying to do.  So, Fireplace would then look like this:

class Fireplace():
   def __init__(self, controller):
       self.controller = controller
       main_floor = self.controller.frames["MainFloor"]

       if (bus1.read_pin(15) == 1):
           bus1.write_pin(15, 0)
           main_floor.toggleButton1["text"] = ("Fireplace On")
       else:
           bus1.write_pin(15, 1)
           main_floor.toggleButton1["text"] = ("Fireplace Off")
Reply


Messages In This Thread
RE: Multi windows in tkinter buttons not responding correctly - by nilamo - Jun-30-2017, 06:57 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Tkinter & Application flow issues - using multi-threaded for GUI caarsonr 4 2,047 Jan-06-2025, 01:35 AM
Last Post: deanhystad
Smile Unable to display Devanagari ligatures correctly in python tkinter Anamika 4 1,399 Nov-26-2024, 08:08 PM
Last Post: woooee
  Tkinter multiple windows in the same window hosierycouch 1 1,243 May-30-2024, 04:28 AM
Last Post: deanhystad
  tkinter two windows instead of one jacksfrustration 7 2,511 Feb-08-2024, 06:18 PM
Last Post: deanhystad
  Tkinter multiple windows in the same window tomro91 1 2,176 Oct-30-2023, 02:59 PM
Last Post: Larz60+
  pass a variable between tkinter and toplevel windows janeik 9 6,193 Oct-05-2023, 04:22 AM
Last Post: janeik
  tkinter toggle buttons not working Nu2Python 26 12,191 Jan-23-2022, 06:49 PM
Last Post: Nu2Python
  [PyGTK] How to center text on multi-line buttons? Lomax 3 5,861 Jan-23-2021, 03:23 PM
Last Post: Lomax
  Dual Tkinter windows and shells Astrikor 6 6,479 Sep-03-2020, 10:09 PM
Last Post: Astrikor
  [Tkinter] How to compare two variables correctly in tkinter scratchmyhead 2 4,756 May-10-2020, 08:04 PM
Last Post: scratchmyhead

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020