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)
예제 #2
0
    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
예제 #3
0
    def add_hotkey(self, label_name, keys, func):
        if keys[0].lower() not in map(lambda x: x.lower(), self.modifier_options) or keys[1].lower() not in map(lambda x: x.lower(), self.character_options):
            messagebox.showerror('Invalid hotkey', 'One or several hotkeys are invalid. Please edit/delete mf_config.ini')
            sys.exit()
        default_modifier, default_key = keys
        action = label_name.replace(' ', '_').lower()
        setattr(self, '_' + action, keys)
        lf = tkd.LabelFrame(self, height=30, width=179)
        lf.propagate(False)
        lf.pack(expand=True, fill=tk.BOTH)

        lab = tkd.Label(lf, text=label_name)
        lab.pack(side=tk.LEFT)

        setattr(self, action + '_e', tk.StringVar())
        key = getattr(self, action + '_e')
        key.set(default_key)
        drop2 = ttk.Combobox(lf, textvariable=key, state='readonly', values=self.character_options)
        drop2.bind("<FocusOut>", lambda e: drop2.selection_clear())
        drop2.config(width=9)
        drop2.pack(side=tk.RIGHT, fill=tk.X, padx=2)

        setattr(self, action + '_m', tk.StringVar())
        mod = getattr(self, action + '_m')
        mod.set(default_modifier)
        drop1 = ttk.Combobox(lf, textvariable=mod, state='readonly', values=self.modifier_options)
        drop1.bind("<FocusOut>", lambda e: drop1.selection_clear())
        drop1.config(width=7)
        drop1.pack(side=tk.RIGHT)

        mod.trace_add('write', lambda name, index, mode: self.re_register(action, getattr(self, '_' + action), func))
        key.trace_add('write', lambda name, index, mode: self.re_register(action, getattr(self, '_' + action), func))
        if default_key.lower() != 'no_bind':
            reg_key = [keys[1].lower()] if keys[0] == '' else list(map(lambda x: x.lower(), keys))
            self.hk.register(reg_key, callback=lambda event: '' if win32gui.FindWindow(None, 'Add drop') else self.main_frame.queue.put(func))
예제 #4
0
    def _make_widgets(self):
        bfr1 = tkd.LabelFrame(self, height=28)
        bfr1.propagate(False)
        bfr1.pack(expand=False, fill=tk.X, padx=1, pady=1)

        tkd.Button(bfr1, text='Sync', width=6, command=self.sync_local_grail, relief=tk.RIDGE, borderwidth=1, tooltip='Updates your local grail to include items logged either\nin your profiles or on herokuapp').pack(side=tk.LEFT, padx=[1, 15], pady=1)
        tkd.Checkbutton(bfr1, text='Profiles', variable=self.sync_drops).pack(side=tk.LEFT)
        tkd.Checkbutton(bfr1, text='Herokuapp', variable=self.sync_herokuapp).pack(side=tk.LEFT)

        bfr2 = tkd.Frame(self)
        bfr2.pack(pady=12, expand=True, fill=tk.X)
        tkd.Button(bfr2, text='Upload grail to herokuapp', command=self.upload_to_herokuapp, borderwidth=3, tooltip='This will not delete already found items on herokuapp if they are not\nin your local grail, but only add new items').pack(padx=8, side=tk.LEFT, fill=tk.X, expand=True)

        bfr3 = tkd.Frame(self)
        bfr3.pack(side=tk.BOTTOM, expand=tk.YES, fill=tk.X)
        tkd.Button(bfr3, text='Item table', borderwidth=3, command=self.open_grail_table, width=1).pack(side=tk.LEFT, fill=tk.X, padx=[1, 0], pady=1, expand=tk.YES)
        tkd.Button(bfr3, text='Grail controller', borderwidth=3, command=self.open_grail_controller, width=1).pack(side=tk.LEFT, fill=tk.X, padx=1, pady=1, expand=tk.YES)

        descr = tkd.ListboxFrame(self)
        descr.propagate(False)
        tk.Grid.columnconfigure(descr, 0, weight=1)
        descr.pack(side=tk.BOTTOM, fill=tk.X, expand=False)
        for i, l in enumerate(['', 'Exist', 'Owned', 'Left', '%']):
            tkd.ListboxLabel(descr, text=l).grid(row=0, column=i)
        ttk.Separator(descr, orient=tk.HORIZONTAL).grid(row=1, column=0, columnspan=5, sticky='ew')
        self._make_row(descr, 2, 'Uniq Armor')
        self._make_row(descr, 3, 'Uniq Weapons')
        self._make_row(descr, 4, 'Uniq Other')
        self._make_row(descr, 5, 'Sets')
        self._make_row(descr, 6, 'Runes')
        self._make_row(descr, 7, 'Total')
예제 #5
0
    def make_widgets(self):
        tkd.Label(self, text='Advanced stats tracker',
                  font='Helvetica 15').pack()

        lf0 = tkd.LabelFrame(self)
        lf0.pack(expand=False, fill=tk.X, padx=1)
        self.create_row(self.mf_sv, label_name='MF', lf=lf0)
        self.create_row(self.players_x_sv, label_name='Players X', lf=lf0)

        lf1 = tkd.LabelFrame(self)
        lf1.pack(expand=False, fill=tk.X, padx=1, pady=[8, 0])
        self.create_row(self.unique_kills_sv,
                        label_name='Unique kills',
                        lf=lf1)
        self.create_row(self.champ_kills_sv,
                        label_name='Champion kills',
                        lf=lf1)

        self.xp_lf1 = tkd.LabelFrame(self)
        self.xp_lf1.pack(expand=False, fill=tk.X, padx=1, pady=8)
        self.create_row(self.exp_perc_sv, label_name='Exp %', lf=self.xp_lf1)
        self.create_row(self.exp_session_sv,
                        label_name='Exp (session)',
                        lf=self.xp_lf1)
        self.create_row(self.exp_run_sv,
                        label_name='Exp (run)',
                        lf=self.xp_lf1)
        self.create_row(self.exp_hour_sv,
                        label_name='Exp / hour',
                        lf=self.xp_lf1)

        self.xp_lf2 = tkd.LabelFrame(self)
        self.xp_lf2.pack(expand=False, fill=tk.X, padx=1)
        self.create_row(self.exp_level_sv,
                        label_name='Exp to level',
                        lf=self.xp_lf2)
        self.create_row(self.hours_level_sv,
                        label_name='Time to level',
                        lf=self.xp_lf2)
        self.create_row(self.runs_level_sv,
                        label_name='Runs to level',
                        lf=self.xp_lf2)
예제 #6
0
    def __init__(self, main_frame, **kw):
        tkd.Frame.__init__(self, main_frame.root, **kw)
        self.main_frame = main_frame

        self.session_char_xp_start = 0
        self.session_char_xp = 0
        self.session_char_time_start = time.time()
        self.session_char_xp_missing = 0
        self.avg_run = 0
        self.session_xp_runs = set()

        # ==================================== WIDGETS ==================================== #
        tkd.Label(self, text='Advanced stats tracker',
                  font='Helvetica 15').pack()

        lf1 = tkd.LabelFrame(self)
        lf1.pack(expand=False, fill=tk.X, padx=1)
        self.name_sv = self.create_row('Name', lf=lf1, default_val='-----')
        self.level_sv = self.create_row('Level', lf=lf1, default_val='-----')
        self.mf_sv = self.create_row('MF', lf=lf1, default_val='-----')
        self.players_x_sv = self.create_row('Players X',
                                            lf=lf1,
                                            default_val='-----')

        lf2 = tkd.LabelFrame(self)
        lf2.pack(expand=False, fill=tk.X, padx=1, pady=8)
        self.exp_sv = self.create_row('Exp %', lf=lf2)
        self.exp_session_sv = self.create_row('Exp (session)', lf=lf2)
        self.exp_run_sv = self.create_row('Exp (run)', lf=lf2)
        self.exp_hour_sv = self.create_row('Exp / hour', lf=lf2)

        lf3 = tkd.LabelFrame(self)
        lf3.pack(expand=False, fill=tk.X, padx=1)
        self.exp_level_sv = self.create_row('Exp to level', lf=lf3)
        self.hours_level_sv = self.create_row('Time to level', lf=lf3)
        self.runs_level_sv = self.create_row('Runs to level', lf=lf3)
        # ==================================== WIDGETS ==================================== #

        color_themes.Theme(main_frame.active_theme).update_colors()
예제 #7
0
    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
예제 #8
0
    def add_num_entry(self, flag_name, comment=None):
        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=flag_name)
        lab.pack(side=tk.LEFT)
        if comment is not None:
            tkd.create_tooltip(lab, comment)

        flag_attr = flag_name.lower().replace(' ', '_').replace('-', '_').replace('(', '').replace(')', '')
        setattr(self, flag_attr + '_sv', tk.StringVar())
        sv = getattr(self, flag_attr + '_sv')
        sv.set(other_utils.safe_eval(self.main_frame.cfg['OPTIONS'][flag_attr]))
        tkd.RestrictedEntry(lf, textvariable=sv, num_only=True, width=13).pack(side=tk.RIGHT, padx=3)
        sv.trace_add('write', lambda name, index, mode: setattr(self.main_frame, flag_attr, float('0' + sv.get())))
예제 #9
0
    def add_theme_choice(self, comment=None):
        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='Active theme')
        lab.pack(side=tk.LEFT)
        if comment is not None:
            tkd.create_tooltip(lab, comment)

        self.active_theme = tk.StringVar()
        self.active_theme.set(self.main_frame.active_theme)
        theme_choices = tkd.Combobox(lf, textvariable=self.active_theme, state='readonly', values=available_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)
예제 #10
0
    def make_widgets(self):
        self.gamemode_frame = tkd.LabelFrame(self,
                                             height=LAB_HEIGHT,
                                             width=LAB_WIDTH)
        self.gamemode_frame.propagate(False)

        self.gamemode_lab = tkd.Label(
            self.gamemode_frame,
            text='Game mode',
            tooltip=
            'If Multiplayer is selected, the .map file is used to check for updates.\n'
            'Thus, new runs begin every time you enter a new game (since your local .map files will be updated by this)\n\n'
            'If Single Player is selected the .d2s file is used to check for updates.\n'
            'Thus, a new run begins every time you leave a game (since your .d2s files are saved upon exit)'
        )

        self.game_mode = tk.StringVar()
        self.game_mode.set(self.main_frame.profile_tab.game_mode.get())
        self.gamemode_cb = ttk.Combobox(
            self.gamemode_frame,
            textvariable=self.game_mode,
            state='readonly',
            values=['Single Player', 'Multiplayer'])
        self.gamemode_cb.bind("<FocusOut>",
                              lambda e: self.gamemode_cb.selection_clear())
        self.gamemode_cb.config(width=11)
        self.game_mode.trace_add(
            'write', lambda name, index, mode: self.update_game_mode())

        self.charname_frame = tkd.LabelFrame(self,
                                             height=LAB_HEIGHT,
                                             width=LAB_WIDTH)
        self.charname_frame.propagate(False)

        self.char_var = tk.StringVar()
        self.char_var.set(self.main_frame.profile_tab.char_name.get())
        self.charname_text_lab = tkd.Label(
            self.charname_frame,
            text='Character name',
            tooltip='Your character name is inferred from the active profile.\n'
            'Make sure the character name in your profile is matching your in-game character name'
        )
        self.charname_val_lab = tkd.Label(self.charname_frame,
                                          textvariable=self.char_var)

        self.sp_path_lab = tkd.Label(self, text='Game path (Single Player)')
        self.SP_game_path = tk.StringVar()
        self.SP_game_path.set(self.main_frame.SP_game_path)
        self.sp_path_entry = tkd.Entry(self, textvariable=self.SP_game_path)

        self.sp_path_frame = tkd.Frame(self)
        self.sp_path_get = tkd.Button(
            self.sp_path_frame,
            text='Get',
            command=lambda: self.get_game_path(is_sp=True),
            tooltip=
            'The app tries to automatically find your game path for single player\n'
            'If nothing is returned you have to type it in manually')
        self.sp_path_apply = tkd.Button(
            self.sp_path_frame,
            text='Apply',
            command=self.apply_path_ch,
            tooltip='Apply the current specified path')

        self.mp_path_lab = tkd.Label(self, text='Game path (Multiplayer)')
        self.MP_game_path = tk.StringVar()
        self.MP_game_path.set(self.main_frame.MP_game_path)
        self.mp_path_entry = tkd.Entry(self, textvariable=self.MP_game_path)
        self.mp_path_frame = tkd.Frame(self)

        self.mp_path_get = tkd.Button(
            self.mp_path_frame,
            text='Get',
            command=lambda: self.get_game_path(is_sp=False),
            tooltip=
            'The app tries to automatically find your game path for multiplayer\n'
            'If nothing is returned you have to type it in manually')
        self.mp_path_apply = tkd.Button(
            self.mp_path_frame,
            text='Apply',
            command=self.apply_path_ch,
            tooltip='Apply the current specified path')

        # Stuff for advanced mode
        self.advanced_mode_stop = self.add_flag(
            flag_name='Stop when leaving',
            comment=
            'On: Stops the current run when you exit to menu.\nOff: The run counter will continue ticking until you enter a new game',
            pack=False,
            config_section='AUTOMODE')
        self.advanced_pause_on_esc_menu = self.add_flag(
            flag_name='Pause on ESC menu',
            comment=
            'When activated, the counter will be paused when ESC menu\nis open inside d2 (not working for 1.14b and 1.14c)',
            pack=False,
            config_section='AUTOMODE')
        self.advanced_automode_warning = tkd.Label(
            self,
            text='"Advanced automode" is highly \n'
            'discouraged when playing\n'
            'multiplayer, as it might result\n'
            'in a ban.\n'
            'Explanation: Advanced automode\n'
            'utilizes "memory reading" of the\n'
            'D2 process to discover information\n'
            'about the current game state,\n'
            'and this could be deemed cheating.',
            justify=tk.LEFT)

        self.toggle_automode_btn(first=True)