tech_radioButton1 = ttk.Radiobutton(selection_frame_1, text="ANT+", variable = self.tech_var, value = 1, command = self.tech_select)
tech_radioButton1.pack(side = 'top')
tech_radioButton2 = ttk.Radiobutton(selection_frame_1, text="Bluetooth", variable = self.tech_var, value = 2, command = self.tech_select)
tech_radioButton2.pack(side = 'top')
tech_radioButton3 = ttk.Radiobutton(selection_frame_1, text="BTLE", variable = self.tech_var, value = 3, command = self.tech_select)
tech_radioButton3.pack(side = 'top')
tech_radioButton4 = ttk.Radiobutton(selection_frame_1, text="WLAN", variable = self.tech_var, value = 4, command = self.tech_select)
tech_radioButton4.pack(side = 'top')
tech_radioButton5 = ttk.Radiobutton(selection_frame_1, text="UNII", variable = self.tech_var, value = 5, command = self.tech_select)
tech_radioButton5.pack(side = 'top')
我的项目中有一组单选按钮的代码段,当我运行它时看起来像这样:
我想将它们全部固定在西边,这样它们的左侧就会垂直对齐。我尝试使用tk代替ttk(因为在ttk中没有锚选项)radiobutton并设置anchor ='w',但它们仍然如下所示:
有人可以帮忙吗? TIA
答案 0 :(得分:1)
tech_radioButton1 = ttk.Radiobutton(selection_frame_1, text="ANT+", variable = self.tech_var, value = 1, command = self.tech_select)
tech_radioButton1.pack(side = 'top', anchor = 'w')
tech_radioButton2 = ttk.Radiobutton(selection_frame_1, text="Bluetooth", variable = self.tech_var, value = 2, command = self.tech_select)
tech_radioButton2.pack(side = 'top', anchor = 'w')
tech_radioButton3 = ttk.Radiobutton(selection_frame_1, text="BTLE", variable = self.tech_var, value = 3, command = self.tech_select)
tech_radioButton3.pack(side = 'top', anchor = 'w')
tech_radioButton4 = ttk.Radiobutton(selection_frame_1, text="WLAN", variable = self.tech_var, value = 4, command = self.tech_select)
tech_radioButton4.pack(side = 'top', anchor = 'w')
tech_radioButton5 = ttk.Radiobutton(selection_frame_1, text="UNII", variable = self.tech_var, value = 5, command = self.tech_select)
tech_radioButton5.pack(side = 'top', anchor = 'w')