python - Tkinter button disable not working -


i'm new python , newer gui programming.

i've got button , 2 spinboxes want disable after click start button. i've googled 5 different ways disable tkinter button , none seem work. theoretically spinboxes should disabled same way i'm not having luck. getting frustrated whole gui thing.

self.gps_com , self.arduino_com 2 spinboxes

as can see tried use update() button doesn't work. i've seen variations of code use disabled in caps, first letter cap'd , different variations of quotes. current syntax gives no warnings/errors spyder.

i thought going easy find answer question i've been @ few hours.

def onbuttonclickstart(self):     self.labelvariable.set( self.entryvariable.get())     self.entry.focus_set()     self.entry.selection_range(0, tkinter.end)     self.button_start.config(state = 'disabled')     self.button_start.update()     self.gps_com.config(state = 'disabled')     self.arduino_com.config(state = 'disabled') 

try piece of code , see if text updates & buttons disable/re-enable expected:

import tkinter tk  class window():      def __init__(self, root):          self.frame = tk.frame(root)         self.frame.grid()          self.i = 0         self.labelvar = tk.stringvar()         self.labelvar.set("this first text: %d" %self.i)           self.label = tk.label(self.frame, text = self.labelvar.get(), textvariable = self.labelvar)         self.label.grid(column = 0, row = 0)          self.button = tk.button(self.frame, text = "update", command = self.updatelabel)         self.button.grid(column = 1, row = 0)          self.enablebutton = tk.button(self.frame, text = "enable update button", state = 'disabled', command = self.enable)         self.enablebutton.grid(column = 2, row = 0)      def updatelabel(self):          self.i += 1         self.labelvar.set("this new text: %d" %self.i)         self.button.config(state = 'disabled')         self.enablebutton.config(state = 'active')      def enable(self):          self.button.config(state = 'active')         self.enablebutton.config(state = 'disabled')  root = tk.tk() window = window(root) root.mainloop() 

if works either a) using wrong keywords ('disabled', lowercase, in python 2.5/3.4 (i tested 3.4 last night)) or b) function trying call not being executed tobias_k suggested.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -