kharri5 0 Junior Poster in Training

Hello,

I have a program written up that is trying to use buttons to turn on and off the radiobuttons themselves. IF the user clicks on the radiobutton itself, then it should have no affect. This simulates a sort of UI touch screen affect, with the radiobuttons themselves looking like LED indicators. The radiobuttons by default should all be uncheck to start. Now. This works in Windows wxPython IDLE program. This does not however work in the Linux I have here at school. I cannot get SetValue to have an affect at all, and all the radiobuttons are checked on when I start the application, which I do not want. I want them only to be checked on when I press a given button. The code for setting them up looks like this:

#variables to see button clicked or not
        self.monOn = False
        self.tueOn = False
        self.wedOn = False
        self.thuOn = False
        self.friOn = False
        self.satOn = False
        self.sunOn = False

        #buttons and their events
        mon = GenBitmapTextButton(weekPanel, 24, wx.Bitmap('mon.jpg'), '', wx.DefaultPosition, (53,34))
        mon.SetBackgroundColour('#284c4c')
        mon.Bind(wx.EVT_BUTTON, self.setMon)
        tue = GenBitmapTextButton(weekPanel, 24, wx.Bitmap('Tue.jpg'), '', wx.DefaultPosition, (53,34))
        tue.SetBackgroundColour('#284c4c')
        tue.Bind(wx.EVT_BUTTON, self.setTue)
        wed = GenBitmapTextButton(weekPanel, 24, wx.Bitmap('wed.jpg'), '', wx.DefaultPosition, (53,34))
        wed.SetBackgroundColour('#284c4c')
        wed.Bind(wx.EVT_BUTTON, self.setWed)
        thu = GenBitmapTextButton(weekPanel, 24, wx.Bitmap('thu.jpg'), '', wx.DefaultPosition, (53,34))
        thu.SetBackgroundColour('#284c4c')
        thu.Bind(wx.EVT_BUTTON, self.setThu)
        fri = GenBitmapTextButton(weekPanel, 24, wx.Bitmap('fri.jpg'), '', wx.DefaultPosition, (53,34))
        fri.SetBackgroundColour('#284c4c')
        fri.Bind(wx.EVT_BUTTON, self.setFri)
        sat = GenBitmapTextButton(weekPanel, 24, wx.Bitmap('sat.jpg'), '', wx.DefaultPosition, (53,34))
        sat.SetBackgroundColour('#284c4c')
        sat.Bind(wx.EVT_BUTTON, self.setSat)
        sun = GenBitmapTextButton(weekPanel, 24, wx.Bitmap('sun.jpg'), '', wx.DefaultPosition, (53,34))
        sun.SetBackgroundColour('#284c4c')
        sun.Bind(wx.EVT_BUTTON, self.setSun)

        #radio buttons for active or not active day of week
        self.monAc = wx.RadioButton(weekPanel, 50, '', (10, 10),style=wx.RB_GROUP)
        self.monAc.SetValue(False)
        self.monAc.Bind(wx.EVT_RADIOBUTTON, self.monActv)
        self.tueAc = wx.RadioButton(weekPanel, 51, '', (10, 10),style=wx.RB_GROUP)
        self.tueAc.SetValue(False)
        self.tueAc.Bind(wx.EVT_RADIOBUTTON, self.tueActv)
        self.wedAc = wx.RadioButton(weekPanel, 52, '', (10, 10),style=wx.RB_GROUP)
        self.wedAc.SetValue(False)
        self.wedAc.Bind(wx.EVT_RADIOBUTTON, self.wedActv)
        self.thuAc = wx.RadioButton(weekPanel, 53, '', (10, 10),style=wx.RB_GROUP)
        self.thuAc.SetValue(False)
        self.thuAc.Bind(wx.EVT_RADIOBUTTON, self.thuActv)    
        self.friAc = wx.RadioButton(weekPanel, 54, '', (10, 10),style=wx.RB_GROUP)
        self.friAc.SetValue(False)
        self.friAc.Bind(wx.EVT_RADIOBUTTON, self.friActv)
        self.satAc = wx.RadioButton(weekPanel, 55, '', (10, 10),style=wx.RB_GROUP)
        self.satAc.SetValue(False)
        self.satAc.Bind(wx.EVT_RADIOBUTTON, self.satActv)
        self.sunAc = wx.RadioButton(weekPanel, 56, '', (10, 10),style=wx.RB_GROUP)
        self.sunAc.SetValue(False)
        self.sunAc.Bind(wx.EVT_RADIOBUTTON, self.sunActv)
        
        weekBox.AddMany([ (mon, 1, wx.ALIGN_CENTER ),
              (tue, 1, wx.ALIGN_CENTER ),
              (wed, 1, wx.ALIGN_CENTER ),
              (thu, 1, wx.ALIGN_CENTER ),
              (fri, 1, wx.ALIGN_CENTER ),
              (sat, 1, wx.ALIGN_CENTER ),
              (sun, 1, wx.ALIGN_CENTER ),
              (self.monAc, 1, wx.ALIGN_CENTER ), 
              (self.tueAc, 1, wx.ALIGN_CENTER ),
              (self.wedAc, 1, wx.ALIGN_CENTER ),
              (self.thuAc, 1, wx.ALIGN_CENTER ),
              (self.friAc, 1, wx.ALIGN_CENTER ),
              (self.satAc, 1, wx.ALIGN_CENTER ),
              (self.sunAc, 1, wx.ALIGN_CENTER ) ])

And then each monday through sunday function looks like this for the button and then the radiobutton indicator respectively.

#these are a group of events for monday through sunday actions
    def setMon(self,event):
        "''"
        if self.monOn == False:
            self.monOn = True
            self.monAc.SetValue(True)
	    self.SetStatusText("Mon On")
        else:
            self.monOn = False
            self.monAc.SetValue(False)
	    self.SetStatusText("Mon Off")

    def monActv(self,event):
        "''"
        if self.monOn == False:
            self.monAc.SetValue(False)
	    self.SetStatusText("Mon Off")
        else:
            self.monAc.SetValue(True)
	    self.SetStatusText("Mon On")

If anyone can help me to figure out why it doesn't work in Linux and also how to make it work, I would greatly appreciate it. Thank you.

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.