Python 2.7 Tkinter - Determine which Radiobutton has been selected

前端 未结 2 1514
半阙折子戏
半阙折子戏 2020-12-21 10:38

Assuming the following code has been written:

self.firstRadioButton = Radiobutton(self.__canvas, text="ONE", fg=\'white\', bg=BACKGROUND_COLOR, vari         


        
2条回答
  •  礼貌的吻别
    2020-12-21 11:12

    The way it works - is you do not check which radio buttons is selected, rather you bind a radio button to an event.

    You have to bind the radio button to a function or event. reference these articles: http://www.java2s.com/Tutorial/Python/0360__Tkinker/BindvariabletoRadioButton.htm http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm

    Try something similar to:

    self.secondRadioButton.bind('', self.__function_name_that_should_run_when_radiobtn_selected)
    

提交回复
热议问题