Как избежать перемещения других виджетов в tkinter при изменении размера метки? - PullRequest
0 голосов
/ 09 апреля 2020

В моем GUI есть метка, которая меняет размер при выборе. Однако это также вызывает перемещение переключателей рядом, когда размер этикетки изменяется. Как мне сохранить флажки в фиксированном положении. Мой код выглядит следующим образом для соответствующих виджетов:

        #configuring the radiobuttons
        self.confirmedbutton = tk.Checkbutton(self,text = 'Confirmed Cases',variable = self.death, onvalue = 1,offvalue = 0)
        self.confirmedbutton.grid(row = 6, column = 1,padx = 10,pady = 10,sticky = 'w')
        self.confirmedbutton.deselect()

        self.deathbutton = tk.Checkbutton(self,text = 'Deaths',variable = self.confirmed, onvalue = 1,offvalue = 0)
        self.deathbutton.grid(row = 7, column = 1,padx = 10,pady = 10,sticky = 'w')
        self.deathbutton.deselect()

        self.recoveredbutton = tk.Checkbutton(self,text = 'Recovered Cases',variable = self.recovered, onvalue = 1,offvalue = 0)
        self.recoveredbutton.grid(row = 8, column = 1,padx = 10,pady = 10, sticky = 'w')
        self.recoveredbutton.deselect()

        #button to load countries for plotting
        self.loadcountrytolabel = tk.Button(self, text = 'Load Country', command = lambda: self.loadcountryforplotting(self.region.get()))
        self.loadcountrytolabel.grid(row = 6, column = 2, padx = 10, pady = 10)

        #label that changes size
        self.textval = 'Selected Countries:'
        self.selectcountries = tk.Label(self, text = 'Selected Countries:', relief = 'sunken')
        self.selectcountries.grid(row = 7, column = 2, padx = 10, pady = 10, ipadx = 10)
        self.selectcountries.grid_propagate(0)

def loadcountryforplotting(self, selectedcountry):
        self.listofselectedcountries = list()
        self.listofselectedcountries.append(selectedcountry)


        for country in self.listofselectedcountries:
            self.textval = self.textval +  '\n' + country

        self.selectcountries.config(text = self.textval)

enter image description here enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...