def make_widgets(self): tkd.Label(self.root, text='This is a test application').pack() # Create a test row lf1 = tkd.LabelFrame(self.root) lf1.pack(expand=True, fill=tk.X) svar = tk.IntVar(value=0) tkd.Label(lf1, text='Option 1').pack(side=tk.LEFT) tkd.Radiobutton(lf1, text='Off', indicatoron=False, value=0, variable=svar).pack(side=tk.RIGHT) tkd.Radiobutton(lf1, text='On', indicatoron=False, value=1, variable=svar).pack(side=tk.RIGHT) # Create choice to change theme lf2 = tkd.LabelFrame(self.root) lf2.pack(expand=True, fill=tk.X) tkd.Label(lf2, text='Active theme').pack(side=tk.LEFT) theme_choices = ttk.Combobox(lf2, textvariable=self.theme_var, state='readonly', values=themes) theme_choices.bind("<FocusOut>", lambda e: theme_choices.selection_clear()) theme_choices.bind("<<ComboboxSelected>>", lambda e: self._change_theme()) theme_choices.config(width=11) theme_choices.pack(side=tk.RIGHT, fill=tk.X, padx=2)
def add_flag(self, flag_name, comment=None, pack=True, config_section='OPTIONS'): lf = tkd.LabelFrame(self, height=LAB_HEIGHT, width=LAB_WIDTH) lf.propagate(False) if pack: lf.pack(expand=False, fill=tk.X) lab = tkd.Label(lf, text=flag_name) lab.pack(side=tk.LEFT) if comment is not None: tkd.create_tooltip(lab, comment) flag_attr = flag_name.lower().replace(' ', '_').replace('-', '_') setattr(self, flag_attr, tk.StringVar(lf)) sv = getattr(self, flag_attr) off_button = tkd.Radiobutton(lf, text='Off', variable=sv, indicatoron=False, value=False, width=4, padx=4) on_button = tkd.Radiobutton(lf, text='On', variable=sv, indicatoron=False, value=True, width=4, padx=3) if other_utils.safe_eval(self.main_frame.cfg[config_section][flag_attr]): on_button.invoke() setattr(self, flag_attr + '_invoked', True) else: off_button.invoke() setattr(self, flag_attr + '_invoked', False) off_button.config(command=lambda: self.toggle_button(flag_attr)) on_button.config(command=lambda: self.toggle_button(flag_attr)) on_button.pack(side=tk.RIGHT) off_button.pack(side=tk.RIGHT) return lf
def add_automode_flag(self): lf = tkd.LabelFrame(self, height=LAB_HEIGHT, width=LAB_WIDTH) lf.propagate(False) lf.pack(expand=False, fill=tk.X) lab = tkd.Label( lf, text='Automode', tooltip= 'Enable automode for monitoring when you enter and exit games') lab.pack(side=tk.LEFT) self.automode_var = tk.StringVar(lf) off_btn = tkd.Radiobutton(lf, text='Off', variable=self.automode_var, indicatoron=False, value=0, width=5, padx=4) simple_btn = tkd.Radiobutton(lf, text='Simple', variable=self.automode_var, indicatoron=False, value=1, width=5, padx=3) adv_btn = tkd.Radiobutton(lf, text='Advanced', variable=self.automode_var, indicatoron=False, value=2, width=7, padx=3) cfg_mode = other_utils.safe_eval( self.main_frame.cfg['AUTOMODE']['automode']) if cfg_mode == 2: adv_btn.invoke() elif cfg_mode == 1: simple_btn.invoke() else: off_btn.invoke() off_btn.config(command=self.toggle_automode_btn) simple_btn.config(command=self.toggle_automode_btn) adv_btn.config(command=self.toggle_automode_btn) adv_btn.pack(side=tk.RIGHT) simple_btn.pack(side=tk.RIGHT) off_btn.pack(side=tk.RIGHT) return off_btn, simple_btn, adv_btn