Пример #1
0
    def __init__(self, app):
        tk.Toplevel.__init__(self)
        self.app = app
        self.char = app.char

        # tk variables ...
        self.xp_var = tk.StringVar()
        self.event_name = tk.StringVar()
        self.money_amount = tk.StringVar()
        self.selected_account = tk.StringVar()
        # build screen
        self.title(msg.IW_TITLE)

        # event name
        self.event_frame = tk.LabelFrame(self, text=msg.IW_EVENT)
        self.event_text = tk.Entry(self.event_frame,
                                   textvariable=self.event_name,
                                   width=50)
        self.event_text.pack(fill=tk.X)
        self.event_frame.pack(fill=tk.X)

        # xp frame
        self.xp_frame = tk.LabelFrame(self, text=msg.IW_XP)
        self.xp_spinbox = tk.Spinbox(self.xp_frame,
                                     textvariable=self.xp_var,
                                     from_=-100,
                                     to=100,
                                     width=4,
                                     font="Arial 12 bold")
        self.xp_var.set("0")
        self.xp_spinbox.pack(fill=tk.X)
        self.xp_frame.pack(fill=tk.X)

        # money frame
        self.money_frame = tk.LabelFrame(self, text=msg.IW_MONEY)
        self.money_amount.set("0")
        self.money_entry = tk.Entry(self.money_frame,
                                    textvariable=self.money_amount,
                                    font="Arial 12 bold")
        self.money_entry.pack(fill=tk.X)
        self.account_label = tk.Label(self.money_frame, text=msg.IW_ACCOUNT)
        accounts = self.buildAccountList()
        width = 0
        for account in accounts:
            if len(account) >= width: width = len(account)
        self.selected_account.set(accounts[0])
        account_selector = tk.OptionMenu(self.money_frame,
                                         self.selected_account, *accounts)
        account_selector.config(width=width)
        account_selector.pack(fill=tk.X)
        self.money_frame.pack(fill=tk.X)

        # submit button
        self.submit = tk.Button(self, text=msg.IW_ADD, command=self._addEvent)
        self.submit.pack(fill=tk.X)

        self.event_name.trace("w", self._check)
        self.money_amount.trace("w", self._check)
        self.xp_var.trace("w", self._check)
        self.event_name.set("")
Пример #2
0
    def __init__(self,main,app):
        tk.Frame.__init__(self,main)
        self.app = app
        self.char = app.char

        self.ewt00 = ImageTk.PhotoImage(file="img/ewt_00.png")
        self.ewt05 = ImageTk.PhotoImage(file="img/ewt_05.png")
        self.ewt10 = ImageTk.PhotoImage(file="img/ewt_10.png")
        self.ewt20 = ImageTk.PhotoImage(file="img/ewt_20.png")

        # this var holds the entry field ...
        self.roll_var = tk.StringVar()

        # setting up the frames
        self.left_frame = tk.Frame(self)
        self.ewt_frame = tk.Frame(self.left_frame)
        self.showEWT(self.ewt_frame)
        self.ewt_frame.pack()

        self.roll_frame = tk.Frame(self.left_frame)
        self.showRollFrame(self.roll_frame)
        self.roll_frame.pack(fill=tk.X)

        self.left_frame.pack(side=tk.LEFT)

        self.result_frame = tk.Frame(self)
        self.result_frame.pack(side=tk.LEFT, anchor=tk.N)
Пример #3
0
    def editModeSwitcher(self, parent):
        """ create a frame with the edit modes 
        
        Note: 
            registers a tk.StringVar for the selected mode
        
        Args:
            parent (tk.Widget): the master widget
        
        Returns:
            tk.LabelFrame: the selector 
        """

        var = self.data["editmode"] = tk.StringVar()

        frame = tk.LabelFrame(parent, text=msg.SET_EDIT_MODE)
        modes = [(msg.SET_EDIT_GENERATION, cd.GENERATION),
                 (msg.SET_EDIT_EDIT, cd.EDIT), (msg.SET_EDIT_VIEW, cd.VIEW),
                 (msg.SET_EDIT_SIM, cd.SIMULATION)]
        for txt, val in modes:
            button = tk.Radiobutton(
                frame,
                text=txt,
                variable=var,
                value=val,
            )
            button.deselect()
            button.pack(anchor=tk.W)

        var.set(self.char.getEditMode())

        return frame
    def __init__(self, main, app):
        tk.Frame.__init__(self, main)
        self.app = app
        self.char = app.char
        self.open_windows = app.open_windows
        self.widgets = {}

        self.template = None
        self.grid = []

        self.active_page = 1
        self.pages = 0

        self._getTemplate()
        if self.template is None:
            self.template = self._newTemplate()

        self.pages = len(self.template.findall("page"))

        # for display ..
        self.cur_page = tk.StringVar()
        page_label = "{page} / {pages}".format(page=str(self.active_page),
                                               pages=str(self.pages))
        self.cur_page.set(page_label)

        self.page_frame = tk.Frame(self)
        self.page_canvas = tk.Canvas(self.page_frame,
                                     width=1,
                                     height=1,
                                     borderwidth=0,
                                     highlightthickness=0,
                                     relief=tk.FLAT,
                                     bg="#ffffff")
        self.page_canvas.pack(fill=tk.BOTH, expand=1)
        self.page_canvas.bind("<Button-1>", self._editModule)
        self.page_canvas.bind("<Configure>",
                              lambda event: self.showPage(self.page_canvas))
        self.page_frame.pack(fill=tk.BOTH, expand=1)
        self.control_frame = tk.Frame(self)
        self.showControl(self.control_frame)
        self._switchPage(0)
        self.control_frame.pack(fill=tk.X)
Пример #5
0
    def _newModule(self, frame):
        tk.Label(frame, text=msg.ME_NEW).pack(fill=tk.X, expand=1)

        mod_types = (
            msg.PDF_ATTRIBUTES,
            msg.PDF_TRAITS,
            msg.PDF_SKILLS,
            msg.PDF_EQUIPMENT,
            msg.PDF_WEAPONS,
            msg.PDF_CONTACTS,
            msg.PDF_EWT,
            msg.PDF_IMAGE,
            msg.PDF_NOTES)
        # this will be the frame for the option selection ... 

        selected_type = tk.StringVar()
        
        selected_type.trace("w", self._modTypeChanged)
        self.vars[str(selected_type)] = selected_type
        self.var_names["module"] = str(selected_type)
        select_button = tk.OptionMenu(
            frame,
            selected_type,
            *mod_types)
        selected_type.set(mod_types[0])
        select_button.pack(fill=tk.X, expand=1)
        row = str(self.row)
        col = str(self.col)
        id = str(self.main.getHighestModuleId()+1)
        
        sub_frame = tk.Frame(frame)
        self.widgets["options"] = option_frame = tk.Frame(sub_frame)
        
        option_frame.pack(fill=tk.X)

        selected_type.set(mod_types[0])

        sub_frame.pack(fill=tk.BOTH, expand=1)
        add_button = tk.Button(frame, text=msg.ME_ADD, command=self._addModule)
        add_button.pack(fill=tk.X)
    def __init__(self, main, app):
        tk.Frame.__init__(self, main)
        self.app = app
        self.char = app.char
        self.itemlist = app.itemlist

        self.canvas_width = 0

        self.account_info = tk.StringVar()

        self.active_bag_id = -1
        self.open_windows = app.open_windows

        # define the three columns
        self.left_frame = tk.Frame(self)
        self.left_frame.place(relx=0,
                              rely=0,
                              relwidth=1 / 3,
                              relheight=1,
                              anchor=tk.NW)

        # displaying the characters initial account
        self.initial_account_frame = self.initialAccount(self.left_frame)
        self.initial_account_frame.pack(fill=tk.X)

        self.updateInitialAccount()

        # a button to buy new stuff (opens the InventoryEditor)
        self.buy_button = tk.Button(self.left_frame,
                                    text=msg.ES_BUY_BUTTON,
                                    command=self.displayInventoryEditor)
        self.buy_button.pack(fill=tk.X)

        # show equipped items
        self.equipped_frame = tk.LabelFrame(self.left_frame,
                                            text=msg.ES_EQUIPPED,
                                            font=config.Style.TITLE_LF_FONT)
        self.equipped_canvas = tk.Canvas(self.equipped_frame,
                                         width=1,
                                         height=1)
        self.equipped_canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
        self.equipped_scroll = tk.Scrollbar(self.equipped_frame,
                                            orient=tk.VERTICAL)
        self.equipped_scroll.pack(side=tk.LEFT, fill=tk.Y)
        self.equipped_scroll.config(command=self.equipped_canvas.yview)
        self.equipped_canvas.config(yscrollcommand=self.equipped_scroll.set)
        self.equipped_frame.pack(fill=tk.BOTH, expand=1)
        self.showEquippedItems()

        # center frame
        # used for the weapons
        self.center_frame = tk.Frame(self)
        self.melee_frame = tk.LabelFrame(self.center_frame,
                                         text=msg.ES_MELEE,
                                         font=config.Style.TITLE_LF_FONT)
        self.melee_canvas = tk.Canvas(self.melee_frame, width=1, height=1)
        self.melee_canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
        self.melee_scroll = tk.Scrollbar(self.melee_frame, orient=tk.VERTICAL)
        self.melee_scroll.pack(side=tk.LEFT, fill=tk.Y)
        self.melee_scroll.config(command=self.melee_canvas.yview)
        self.melee_canvas.config(yscrollcommand=self.melee_scroll.set)
        self.melee_frame.place(relx=0,
                               rely=0,
                               relwidth=1,
                               relheight=.5,
                               anchor=tk.NW)

        self.guns_frame = tk.LabelFrame(self.center_frame,
                                        text=msg.ES_GUNS,
                                        font=config.Style.TITLE_LF_FONT)
        self.guns_canvas = tk.Canvas(self.guns_frame, width=1, height=1)
        self.guns_canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
        self.guns_scroll = tk.Scrollbar(self.guns_frame, orient=tk.VERTICAL)
        self.guns_scroll.pack(side=tk.LEFT, fill=tk.Y)
        self.guns_scroll.config(command=self.guns_canvas.yview)
        self.guns_canvas.config(yscrollcommand=self.guns_scroll.set)

        self.guns_frame.place(relx=0,
                              rely=0.5,
                              relwidth=1,
                              relheight=.5,
                              anchor=tk.NW)
        self.center_frame.place(relx=1 / 3,
                                rely=0,
                                relwidth=1 / 3,
                                relheight=1,
                                anchor=tk.NW)
        self.showEquippedGuns(self.guns_canvas)
        self.showEquippedMelee(self.melee_canvas)

        # the right frame is used for unassigned items
        self.right_frame = tk.Frame(self)
        self.unassigned_frame = tk.LabelFrame(self.right_frame,
                                              text=msg.ES_UNASSIGNED,
                                              font=config.Style.TITLE_LF_FONT)
        self.unassigned_canvas = tk.Canvas(self.unassigned_frame,
                                           height=1,
                                           width=1)
        self.unassigned_canvas.bind("<Configure>", self.updateItemList)
        self.unassigned_canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
        self.unassigned_scroll = tk.Scrollbar(self.unassigned_frame,
                                              orient=tk.VERTICAL)
        self.unassigned_scroll.pack(side=tk.LEFT, fill=tk.Y)
        self.unassigned_scroll.config(command=self.unassigned_canvas.yview)
        self.unassigned_canvas.config(
            yscrollcommand=self.unassigned_scroll.set)
        self.unassigned_frame.place(relx=0,
                                    rely=0,
                                    relwidth=1,
                                    relheight=1,
                                    anchor=tk.NW)
        self.right_frame.place(relx=2 / 3,
                               rely=0,
                               relwidth=1 / 3,
                               relheight=1,
                               anchor=tk.NW)
        self.showUnassignedItems()
Пример #7
0
    def _editModule(self, frame):
        tk.Label(frame, text=msg.ME_EDIT).pack()
        mod_type = self.module.get("type")

        # change size ... 
        self.space = self._getSpace()
        sizes = self._potentialSizes()

        if mod_type == page.MOD_ATTRIBUTES:
            if msg.PDF_DOUBLE in sizes:
                sizes = [msg.PDF_DOUBLE]
            else:
                sizes = [""]

        if mod_type == page.MOD_EWT:
            if msg.PDF_SINGLE in sizes:
                sizes = [msg.PDF_SINGLE]
            else:
                sizes = [""]
        
        tk.Label(frame, text=msg.ME_CHANGE_SIZE).pack()
        size = tk.StringVar()
        self.vars[str(size)] = size
        self.var_names["size"] = str(size)
        
        cur_size = self.module.get("size")

        size_names = {
            page.SINGLE: msg.PDF_SINGLE,
            page.WIDE: msg.PDF_WIDE,
            page.DOUBLE: msg.PDF_DOUBLE,
            page.QUART: msg.PDF_QUART,
            page.TRIPLE: msg.PDF_TRIPLE,
            page.BIG: msg.PDF_BIG,
            page.FULL: msg.PDF_FULL,
            page.HALF: msg.PDF_HALF
        }
        cur_size = size_names[cur_size]
        
        size_button = tk.OptionMenu(
            frame,
            size,
            *sizes
        )
        size.set(cur_size)
        size_button.pack(fill=tk.X)
        if mod_type in [
            page.MOD_TRAITS,
            page.MOD_WEAPONS,
            page.MOD_EQUIPMENT,
            page.MOD_CONTACTS
        ]:
            info_lines = tk.StringVar()
            self.vars[str(info_lines)] = info_lines
            self.var_names["info_lines"] = str(info_lines)
            info_lines_tag = self.module.find("param[@name='info_lines']")
            if info_lines_tag is not None:
                info_lines.set(info_lines_tag.get("value", "0"))
            else:
                info_lines.set("0")
            sub_frame = tk.Frame(frame)
            tk.Label(sub_frame, text=msg.ME_TEXTLINES).pack(side=tk.LEFT)
            tk.Spinbox(
                sub_frame,
                textvariable=info_lines,
                from_=0,
                to=5,
                width=2
            ).pack(side=tk.LEFT)
            sub_frame.pack()

        tk.Button(frame, text=msg.ME_SAVE, command=self._updateModule).pack()
        tk.Button(frame, text=msg.ME_DELETE, command=self._removeModule).pack()
Пример #8
0
    def _modTypeChanged(self, name, e, m):
        selected = self.vars[name].get()
       
        try:  
            frame = self.widgets["options"]
        except KeyError:
            frame = None

        if frame: 
            # cleanup ... 
            widgets = frame.winfo_children()
            for widget in widgets:
                widget.destroy()

            row = str(self.row)
            col = str(self.col)

            sizes = self._potentialSizes()

            if selected == msg.PDF_ATTRIBUTES:
                if msg.PDF_DOUBLE in sizes:
                    sizes = [msg.PDF_DOUBLE]
                else:
                    sizes = [""]

            if selected == msg.PDF_EWT:
                if msg.PDF_SINGLE in sizes:
                    sizes = [msg.PDF_SINGLE]
                else:
                    sizes = [""]

            size = tk.StringVar()
            self.vars[str(size)] = size
            self.var_names["size"] = str(size)
            size_button = tk.OptionMenu(
                frame,
                size,
                *sizes
            )
            size.set(sizes[0])
            size_button.pack(fill=tk.X)

            if selected == msg.PDF_TRAITS: 
                """
                trait_type = "all", 
                info_lines = 1, 
                start_index = 0
                """
                trait_types = [
                    msg.PDF_ALL_TRAITS,
                    msg.PDF_POSITIVE_TRAITS,
                    msg.PDF_NEGATIVE_TRAITS
                ]
                trait_type = tk.StringVar()
                self.vars[str(trait_type)] = trait_type
                self.var_names["trait_type"] = str(trait_type)
                trait_type_button = tk.OptionMenu(
                    frame,
                    trait_type,
                    *trait_types
                )
                trait_type.set(trait_types[0])
                trait_type_button.pack(fill=tk.X)

                info_lines = tk.StringVar()
                self.vars[str(info_lines)] = info_lines
                self.var_names["info_lines"] = str(info_lines)
                info_lines.set("0")
                info_lines_frame = tk.Frame(frame)
                info_lines_label = tk.Label(
                    info_lines_frame,
                    text=msg.ME_TEXTLINES
                )
                info_lines_label.pack(side=tk.LEFT)
                info_lines_spinner = tk.Spinbox(
                    frame,
                    from_=0,
                    to=5,
                    textvariable=info_lines,
                    width=2)
                info_lines_spinner.pack(side=tk.LEFT)
                info_lines_frame.pack(fill=tk.X, expand=1)
                
                pass

            if selected == msg.PDF_SKILLS:
                skill_types = [
                    msg.PDF_SKILLS_ALL,
                    msg.PDF_SKILLS_ACTIVE,
                    msg.PDF_SKILLS_PASSIVE,
                    msg.PDF_SKILLS_KNOWLEDGE,
                    msg.PDF_SKILLS_LANGUAGE
                ]

                skill_type = tk.StringVar()
                self.vars[str(skill_type)] = skill_type
                self.var_names["skill_type"] = str(skill_type)
                skill_type_button = tk.OptionMenu(
                    frame,
                    skill_type,
                    *skill_types
                )
                skill_type.set(skill_types[0])
                skill_type_button.pack(fill=tk.X)

            if selected == msg.PDF_WEAPONS:
                variants = [
                    msg.PDF_ALL_WEAPONS,
                    msg.PDF_MELEE,
                    msg.PDF_GUNS,
                    msg.PDF_AMMO
                ]

                variant = tk.StringVar()
                self.vars[str(variant)] = variant
                self.var_names["variant"] = str(variant)
                variant_button = tk.OptionMenu(
                    frame,
                    variant,
                    *variants)
                variant.set(variants[0])
                variant_button.pack(fill=tk.X)

                equipped = tk.IntVar()
                self.vars[str(equipped)] = equipped
                self.var_names["equipped"] = str(equipped)
                equipped.set(0)

                tk.Checkbutton(
                    frame,
                    text=msg.ME_EQUIPPED_WEAPONS,
                    variable=equipped,
                    offvalue=0,
                    onvalue=1
                ).pack(fill=tk.X)

                amount = tk.IntVar()
                self.vars[str(amount)] = amount
                self.var_names["amount"] = str(amount)
                amount.set(0)

                tk.Checkbutton(
                    frame,
                    text=msg.ME_SHOW_QUANTITY,
                    variable=amount,
                    offvalue=0,
                    onvalue=1
                ).pack(fill=tk.X)

                info_lines = tk.StringVar()
                self.vars[str(info_lines)] = info_lines
                self.var_names["info_lines"] = str(info_lines)
                info_lines.set("0")
                info_lines_frame = tk.Frame(frame)
                info_lines_label = tk.Label(
                    info_lines_frame,
                    text=msg.ME_TEXTLINES
                )
                info_lines_label.pack(side=tk.LEFT)
                info_lines_spinner = tk.Spinbox(
                    frame,
                    from_=0,
                    to=5,
                    textvariable=info_lines,
                    width=2
                )
                info_lines_spinner.pack(side=tk.LEFT)
                info_lines_frame.pack(fill=tk.X, expand=1)

            if selected == msg.PDF_EQUIPMENT:

                item_group = tk.StringVar()
                groups = [
                    msg.PDF_EQUIPMENT_ALL,
                    msg.PDF_EQUIPMENT_CLOTHING,
                    msg.PDF_EQUIPMENT_TOOLS,
                    msg.PDF_EQUIPMENT_BIOTECH,
                    msg.PDF_EQUIPMENT_MONEY
                ]
                self.vars[str(item_group)] = item_group
                self.var_names["item_group"] = str(item_group)
                item_group.set(groups[0])
                labelframe = tk.LabelFrame(frame, text="Gruppe wählen")
                tk.OptionMenu(
                    labelframe,
                    item_group,
                    *groups
                ).pack(fill=tk.X)
                labelframe.pack(fill=tk.X)

                # condense items selection ... 
                condensed = tk.IntVar()
                self.vars[str(condensed)] = condensed
                self.var_names["condensed"] = str(condensed)
                condensed.set(0)
                tk.Checkbutton(
                    frame,
                    text=msg.ME_CONDENSE,
                    variable=condensed,
                    offvalue=0,
                    onvalue=1,
                ).pack(fill=tk.X, expand=1)

                # show only equipped stuff selection
                equipped = tk.IntVar()
                self.vars[str(equipped)] = equipped
                self.var_names["equipped"] = str(equipped)
                equipped.set(0)
                tk.Checkbutton(
                    frame,
                    text=msg.ME_EQUIPPED_STUFF,
                    variable=equipped,
                    offvalue=0,
                    onvalue=1,
                ).pack(fill=tk.X, expand=1)

                # display content selection
                content = tk.IntVar()
                self.vars[str(content)] = content
                self.var_names["content"] = str(content)
                content.set(0)
                tk.Checkbutton(
                    frame,
                    text=msg.ME_BAG_CONTENTS,
                    variable=content,
                    offvalue=0,
                    onvalue=1,
                ).pack(fill=tk.X, expand=1)

                # display weapons selection
                display_weapons = tk.IntVar()
                self.vars[str(display_weapons)] = display_weapons
                self.var_names["display_weapons"] = str(display_weapons)
                display_weapons.set(0)
                tk.Checkbutton(
                    frame,
                    text=msg.ME_SHOW_WEAPONS,
                    variable=display_weapons,
                    offvalue=0,
                    onvalue=1,
                ).pack(fill=tk.X, expand=1)

                # use item_id selector
                use_item_id = tk.IntVar()
                self.vars[str(use_item_id)] = use_item_id
                self.var_names["use_item_id"] = str(use_item_id)
                use_item_id.set(0)
                use_item_id_button = tk.Checkbutton(
                    frame,
                    text=msg.ME_ONLY_BAG,
                    variable=use_item_id,
                    offvalue=0,
                    onvalue=1,
                )
                use_item_id_button.pack(fill=tk.X, expand=1)

                # select items that are bags/containers ... 
                items = self.main.char.getItems()
                containers = [
                    it.CLOTHING,
                    it.BAG,
                    it.CONTAINER,
                    it.BOX,
                    it.TOOLS,
                    it.HARNESS]
                self.vars["bags"] = []
                for item in items:
                    if item.get("type") in containers:
                        container = item.find("container")
                        if container is not None: 
                            item_id = item.get("id")
                            item_name = item.get("name")
                            self.vars["bags"].append(item_id+": "+item_name)

                if len(self.vars["bags"]) == 0:
                    use_item_id_button.config(state=tk.DISABLED)
                else:                          
                    bag_lists = self.vars["bags"]
                    bag_list = tk.StringVar()
                    self.vars[str(bag_list)] = bag_list
                    self.var_names["bag_list"] = str(bag_list)
                    bag_list_button = tk.OptionMenu(
                        frame,
                        bag_list,
                        *bag_lists
                    )
                    bag_list.set(bag_lists[0])
                    bag_list_button.pack()

                # how many info_lines
                info_lines = tk.StringVar()
                self.vars[str(info_lines)] = info_lines
                self.var_names["info_lines"] = str(info_lines)
                info_lines.set("0")
                info_lines_frame = tk.Frame(frame)
                info_lines_label = tk.Label(
                    info_lines_frame,
                    text=msg.ME_TEXTLINES
                )
                info_lines_label.pack(side=tk.LEFT)
                info_lines_spinner = tk.Spinbox(
                    frame,
                    from_=0,
                    to=5,
                    textvariable=info_lines,
                    width=2
                )
                info_lines_spinner.pack(side=tk.LEFT)

                # show weight
                show_weight = tk.IntVar()
                self.vars[str(show_weight)] = show_weight
                self.var_names["show_weight"] = str(show_weight)
                show_weight.set(0)
                tk.Checkbutton(
                    info_lines_frame,
                    text=msg.ME_SHOW_WEIGHT,
                    variable=show_weight,
                    offvalue=0,
                    onvalue=1
                ).pack(side=tk.LEFT)

                # show value
                show_value = tk.IntVar()
                self.vars[str(show_value)] = show_value
                self.var_names["show_value"] = str(show_value)
                show_value.set(0)
                tk.Checkbutton(
                    info_lines_frame,
                    text=msg.ME_SHOW_VALUE,
                    variable=show_value,
                    offvalue=0,
                    onvalue=1
                ).pack(side=tk.LEFT)

                info_lines_frame.pack(fill=tk.X, expand=1)

                # add traces (when everything exists) ...
                condensed.trace("w", self._equipmentOptions)
                equipped.trace("w", self._equipmentOptions)
                content.trace("w", self._equipmentOptions)
                use_item_id.trace("w", self._equipmentOptions)

            if selected == msg.PDF_CONTACTS:
                contact_types = [
                    msg.PDF_ALL_CONTACTS,
                    msg.PDF_FRIENDS,
                    msg.PDF_ENEMIES
                ]

                contact_type = tk.StringVar()
                self.vars[str(contact_type)] = contact_type
                self.var_names["contact_type"] = str(contact_type)
                contact_type_button = tk.OptionMenu(
                    frame,
                    contact_type,
                    *contact_types
                )
                contact_type.set(contact_types[0])
                contact_type_button.pack(fill=tk.X)

                info_lines = tk.StringVar()
                self.vars[str(info_lines)] = info_lines
                self.var_names["info_lines"] = str(info_lines)
                info_lines.set("0")
                info_lines_frame = tk.Frame(frame)
                info_lines_label = tk.Label(
                    info_lines_frame,
                    text=msg.ME_TEXTLINES
                )
                info_lines_label.pack(side=tk.LEFT)
                info_lines_spinner = tk.Spinbox(
                    frame,
                    from_=0,
                    to=5,
                    textvariable=info_lines,
                    width=2
                )
                info_lines_spinner.pack(side=tk.LEFT)
                info_lines_frame.pack(fill=tk.X, expand=1)

            if selected == msg.PDF_NOTES:
                notes = self.main.char.getNotes()
                entries = []
                for note in notes:
                    id = note.get("id", "")
                    name = note.get("name", "")

                    entries.append(id+": "+name)

                if entries:
                    var = tk.StringVar()
                    var.set(msg.ME_NOT_SELECTED)
                    var.trace("w", self._notesEdited)
                    self.vars["id"] = var

                    sub_frame = tk.LabelFrame(frame, text=msg.ME_NOTES)

                    button = tk.OptionMenu(
                        sub_frame,
                        var,
                        *entries
                    )
                    button.pack(fill=tk.X)
                    sub_frame.pack(fill=tk.X)

                title = tk.StringVar()
                self.vars["title"] = title
                title_frame = tk.LabelFrame(frame, text=msg.ME_NOTES_TITLE)
                entry = tk.Entry(title_frame, textvariable=title)
                entry.pack(fill=tk.X)
                title_frame.pack(fill=tk.X)
                title.trace("w", self._notesEdited)

            if selected == msg.PDF_IMAGE:
                pass
Пример #9
0
    def showContact(self, frame):
        """
        This method creates the information screen, adds respective variables and links the traces ...
        frame: the tkinter content frame in which the data shall be shown
        """

        # clear any old widgets ...
        widgets = self.main_screen.winfo_children()
        for widget in widgets:
            widget.destroy()

        # setup the screen and the variables
        self.vars["name"] = tk.StringVar()
        name_frame = tk.LabelFrame(frame, text=msg.NAME)
        name_entry = tk.Entry(name_frame, textvariable=self.vars["name"])
        name_entry.pack(fill=tk.X)
        name_frame.pack(fill=tk.X)

        self.vars["location"] = tk.StringVar()
        location_frame = tk.LabelFrame(frame, text=msg.SE_LOCATION)
        location_entry = tk.Entry(location_frame,
                                  textvariable=self.vars["location"])
        location_entry.pack(fill=tk.X)
        location_frame.pack(fill=tk.X)

        self.vars["competency"] = tk.StringVar()
        self.vars["competency_level"] = tk.StringVar()
        competency_frame = tk.LabelFrame(frame, text=msg.SE_COMPETENCY)
        competency_entry = tk.Entry(competency_frame,
                                    textvariable=self.vars["competency"])
        competency_level = tk.Spinbox(
            competency_frame,
            from_=1,
            to=9,
            textvariable=self.vars["competency_level"],
            width=2)
        competency_entry.pack(side=tk.LEFT, fill=tk.X, expand=1)
        competency_level.pack(side=tk.LEFT, anchor=tk.E)
        competency_frame.pack(fill=tk.X)

        self.vars["loyality"] = tk.StringVar()
        self.vars["loyality_level"] = tk.StringVar()
        loyality_frame = tk.LabelFrame(frame, text=msg.SE_LOYALITY)
        loyality_label = tk.Label(loyality_frame,
                                  textvariable=self.vars["loyality"])
        loyality_label.pack(fill=tk.X)
        loyality_level = tk.Scale(loyality_frame,
                                  from_=-3,
                                  to=3,
                                  variable=self.vars["loyality_level"],
                                  orient=tk.HORIZONTAL)
        loyality_level.pack(fill=tk.X)
        loyality_frame.pack(fill=tk.X)

        self.vars["frequency"] = tk.StringVar()
        self.vars["frequency_level"] = tk.StringVar()
        frequency_frame = tk.LabelFrame(frame, text=msg.SE_FREQUENCY)
        frequency_label = tk.Label(frequency_frame,
                                   textvariable=self.vars["frequency"])
        frequency_label.pack(fill=tk.X)
        frequency_level = tk.Scale(frequency_frame,
                                   from_=0,
                                   to=5,
                                   variable=self.vars["frequency_level"],
                                   orient=tk.HORIZONTAL)
        frequency_level.pack(fill=tk.X)
        frequency_frame.pack(fill=tk.X)

        description_frame = tk.LabelFrame(frame, text=msg.SE_DESCRIPTION)
        description_text = tk.Text(description_frame,
                                   width=40,
                                   height=10,
                                   wrap=tk.WORD,
                                   font="Arial 9")
        description_text.bind("<KeyRelease>", self.descriptionChanged)
        description_text.pack(fill=tk.X)
        description_frame.pack(fill=tk.X)

        # adding the traces ...
        # needs to be down here to make sure all variables exist
        variables = [
            "name", "location", "competency", "competency_level",
            "loyality_level", "frequency_level"
        ]

        for variable in variables:
            self.vars[variable].trace("w", self.dataChanged)

        # TODO: maybe clean this up ...
        self.vars["name"].set(self.contact.get("name"))
        self.vars["location"].set(self.contact.get("location", ""))
        self.vars["loyality_level"].set(self.contact.get("loyality", "0"))
        stored_frequency = float(self.contact.get("frequency", "1.0"))
        frequencies = {0.25: 0, 0.5: 1, 0.75: 2, 1.0: 3, 1.5: 4, 2.0: 5}
        self.vars["frequency_level"].set(frequencies[stored_frequency])
        self.vars["competency_level"].set(
            self.contact.get("competencylevel", "4"))
        self.vars["competency"].set(self.contact.get("competency", ""))

        self.vars["description"] = None
        description = self.contact.find("description")
        if description is not None:
            self.vars["description"] = description.text
        if self.vars["description"] is None:
            self.vars["description"] = ""
        description_text.insert(tk.END, self.vars["description"])
Пример #10
0
    def __init__(self, main, app):
        tk.Frame.__init__(self, main)
        # localize data ...
        # create the character instance # #
        self.app = app
        self.char = app.char
        self.skills = app.skills
        self.traits = app.traits
        self.itemlist = app.itemlist

        # stuff that needs to be available across some functions
        self.global_vars = dict()

        # defining subwindows to track them!
        self.open_windows = app.open_windows

        self.widgets = {}

        # from here on we are building the screen layout ...

        # column 1 ...
        self.frame_1 = frame_1 = tk.Frame(self)
        frame_1.place(relheight=1,
                      relwidth=1 / 12,
                      relx=0,
                      rely=0,
                      anchor=tk.NW)
        # starting with the attribute frame ...
        attr_frame = tk.Frame(frame_1)
        attr_list = self.char.ATTRIB_LIST
        attr_names = [
            msg.PHY, msg.MEN, msg.SOZ, msg.NK, msg.FK, msg.LP, msg.EP, msg.MP
        ]

        edit_mode = self.char.getEditMode()
        for attr, name in zip(attr_list, attr_names):
            frame = tk.LabelFrame(
                attr_frame,
                font=config.Style.ATTR_LF_FONT,
                text=name,
            )
            # initiate the IntVars and bind their tcl names to the attributes
            attrib_values = self.char.attrib_values
            attrib_values[attr] = tk.IntVar()
            attrib_values[attr].set(self.char.getAttributeValue(attr))

            # in generation mode we have spinboxes ...
            if edit_mode == cd.GENERATION:
                self.char.attrib_trace[str(attrib_values[attr])] = attr

                self.widgets[attr] = tk.Spinbox(
                    frame,
                    from_=core.MIN_ATTRIBUTE,
                    to=core.MAX_ATTRIBUTE,
                    font=config.Style.ATTR_FONT,
                    justify=tk.CENTER,
                    textvariable=attrib_values[attr],
                    width=3)
                self.widgets[attr].pack(fill=tk.X)
                self.char.widgets = self.widgets
                self.char.attrib_values[attr].trace("w",
                                                    self.char.attributeChange)

            # in edit mode there are buttons and labels
            if edit_mode == cd.EDIT:
                frame.columnconfigure(0, weight=100)
                value_field = tk.Label(frame,
                                       textvariable=attrib_values[attr],
                                       font=config.Style.ATTR_FONT,
                                       width=3)
                value_field.grid(row=0, column=0, sticky=tk.EW)
                plus = ImageTk.PhotoImage(file="img/plus_s.png")
                self.widgets[attr + "_inc"] = tk.Label(
                    frame,
                    image=plus,
                )
                self.widgets[attr + "_inc"].image = plus
                self.widgets[attr + "_inc"].bind(
                    "<Button-1>",
                    lambda event, attr=attr: self.increaseAttribute(attr))
                self.widgets[attr + "_inc"].grid(row=0, column=1, sticky=tk.EW)
            # in view and sim mode there is only a label ...
            if edit_mode in [cd.VIEW, cd.SIMULATION]:
                value_field = tk.Label(frame,
                                       textvariable=attrib_values[attr],
                                       font=config.Style.ATTR_FONT,
                                       width=3)
                value_field.pack(fill=tk.X, expand=1)

            frame.pack(fill=tk.X)
        attr_frame.pack(fill=tk.X, anchor=tk.N)

        # this displays the characters XP
        xp_frame = tk.LabelFrame(frame_1, text=msg.XP)
        xp_avail = tk.Label(xp_frame, textvariable=self.char.xp_avail)
        self.char.xp_avail.set(self.char.getAvailableXP())
        xp_avail.pack(side=tk.LEFT)
        xp_total_text = " / " + str(self.char.getTotalXP())
        self.xp_total = tk.Label(xp_frame, text=xp_total_text)
        self.xp_total.pack(side=tk.LEFT)
        xp_frame.pack(fill=tk.X)

        # this makes the second block
        frame_2 = tk.Frame(self)

        # beginning with the data frame
        data_frame = tk.LabelFrame(
            frame_2,
            font=config.Style.TITLE_LF_FONT,
            text=msg.CS_BASE_DATA,
        )

        data_list = [[cd.NAME, msg.NAME, 0, 0, 4],
                     [cd.SPECIES, msg.SPECIES, 1, 0, 4],
                     [cd.ORIGIN, msg.ORIGIN, 2, 0, 4],
                     [cd.CONCEPT, msg.CONCEPT, 3, 0, 4],
                     [cd.PLAYER, msg.PLAYER, 4, 0, 4],
                     [cd.HEIGHT, msg.HEIGHT, 5, 0, 1],
                     [cd.WEIGHT, msg.WEIGHT, 5, 1, 1],
                     [cd.AGE, msg.AGE, 5, 2, 1],
                     [cd.GENDER, msg.GENDER, 5, 3, 1],
                     [cd.HAIR, msg.HAIR, 6, 0, 1],
                     [cd.EYES, msg.EYES, 6, 1, 1],
                     [cd.SKIN, msg.SKIN_COLOR, 6, 2, 1],
                     [cd.SKIN_TYPE, msg.SKIN_TYPE, 6, 3, 1]]
        for data in data_list:
            frame = tk.LabelFrame(data_frame, text=data[1])
            # creating a StringVar() and linking the tcl name
            value_var = tk.StringVar()
            self.char.data_values[data[0]] = value_var
            self.char.data_trace[str(value_var)] = data[0]

            # retrieve already stored data from character
            stored_value = self.char.getData(data[0])

            if stored_value:
                value_var.set(stored_value)

            width = 10 * data[4]
            entry = tk.Entry(frame,
                             textvariable=value_var,
                             width=width,
                             **config.Style.DATA_STYLE)
            if edit_mode in [cd.VIEW, cd.SIMULATION]:
                entry.config(state=tk.DISABLED)
            else:
                entry.bind("<FocusOut>", self.dataUpdated)
            entry.pack(fill=tk.BOTH, expand=1)
            frame.grid(row=data[2],
                       column=data[3],
                       columnspan=data[4],
                       sticky="NSWE")

        for row in range(7):
            data_frame.rowconfigure(row, weight=1)
        for col in range(4):
            data_frame.columnconfigure(col, weight=1)
        data_frame.pack(fill=tk.BOTH, anchor=tk.N, expand=1)

        # within this frame will be the character traits
        traits_frame = tk.LabelFrame(
            frame_2,
            font=config.Style.TITLE_LF_FONT,
            text=msg.CS_TRAITS,
        )
        self.traits_text = tk.Text(traits_frame,
                                   bg="#eeeeee",
                                   font="Arial 10",
                                   wrap=tk.WORD,
                                   height=5,
                                   width=10)
        self.updateTraitList()

        # finally pack the field and disable it for editing
        self.traits_text.pack(fill=tk.BOTH, expand=1)
        traits_frame.pack(fill=tk.BOTH, expand=1)

        new_traits_button = tk.Button(frame_2,
                                      text=msg.CS_ADD_TRAIT,
                                      command=self.showTraitWindow)

        if edit_mode in [cd.VIEW, cd.SIMULATION]:
            new_traits_button.config(state=tk.DISABLED)
        new_traits_button.pack(fill=tk.X)

        traits_frame.pack(fill=tk.BOTH, expand=1)
        frame_2.place(relheight=1,
                      relwidth=.4 - 1 / 12,
                      relx=1 / 12,
                      rely=0,
                      anchor=tk.NW)

        # this frame holds the character skills ...
        frame_3 = tk.Frame(self)

        skill_frame = tk.Frame(frame_3)

        # active skills ...
        self.active_skill_frame = tk.LabelFrame(
            skill_frame,
            font=config.Style.TITLE_LF_FONT,
            text=msg.CS_ACTIVE_SKILLS,
        )
        self.active_skill_canvas = tk.Canvas(self.active_skill_frame,
                                             width=1,
                                             height=1)
        self.active_skill_canvas.bind("<Configure>",
                                      lambda event: self.updateSkillList())
        self.active_skill_canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
        self.active_skill_scroll = tk.Scrollbar(self.active_skill_frame,
                                                orient=tk.VERTICAL)
        self.active_skill_scroll.pack(side=tk.LEFT, fill=tk.Y)
        self.active_skill_scroll.config(command=self.active_skill_canvas.yview)
        self.active_skill_canvas.config(
            yscrollcommand=self.active_skill_scroll.set)

        # passive skills
        self.passive_skill_frame = tk.LabelFrame(
            skill_frame,
            font=config.Style.TITLE_LF_FONT,
            text=msg.CS_PASSIVE_SKILLS,
        )
        self.passive_skill_canvas = tk.Canvas(self.passive_skill_frame,
                                              width=1,
                                              height=1)
        self.passive_skill_canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
        self.passive_skill_scroll = tk.Scrollbar(self.passive_skill_frame,
                                                 orient=tk.VERTICAL)
        self.passive_skill_scroll.pack(side=tk.LEFT, fill=tk.Y)
        self.passive_skill_scroll.config(
            command=self.passive_skill_canvas.yview)
        self.passive_skill_canvas.config(
            yscrollcommand=self.passive_skill_scroll.set)

        # initialize the list and place it on screen ...
        self.updateSkillList()
        self.active_skill_frame.place(relx=0,
                                      rely=0,
                                      relwidth=.5,
                                      relheight=1,
                                      anchor=tk.NW)
        self.passive_skill_frame.place(relx=0.5,
                                       rely=0,
                                       relwidth=.5,
                                       relheight=1,
                                       anchor=tk.NW)

        skill_frame.pack(fill=tk.BOTH, expand=1)
        # and a button to add skills
        new_skill_button = tk.Button(frame_3,
                                     text=msg.CS_ADD_SKILLS,
                                     command=self.showSkillWindow)
        if edit_mode in ["view", "simulation"]:
            new_skill_button.config(state=tk.DISABLED)

        new_skill_button.pack(fill=tk.X)
        frame_3.place(relheight=1, relwidth=.6, relx=.4, rely=0, anchor=tk.NW)
Пример #11
0
    def __init__(self, app):
        tk.Toplevel.__init__(self, app)
        #  point to character and skilltree
        self.char = app.char
        self.all_skills = app.skills
        self.app = app
        self.app.open_windows["skill"] = self

        self.minspec = 1
        self.maxspec = 3
        self.origin = ""
        self.complete_list = [skill[0] for skill in self.all_skills.getList()]

        # icons:
        self.unsel_icon = ImageTk.PhotoImage(file="img/unsel.png")
        self.sel_icon = ImageTk.PhotoImage(file="img/sel.png")

        #  build the window
        if self.char.getEditMode == "generation":
            self.title(msg.SS_ADD_REMOVE_SKILLS)
        else:
            self.title(msg.SS_ADD_SKILLS)
        self.protocol("WM_DELETE_WINDOW", self.close)
        self.search_frame = tk.Frame(self)
        self.search = tk.StringVar()
        self.search_gf = tk.Button(self.search_frame,
                                   width=3,
                                   text=msg.SS_BASE,
                                   command=self.toggleMinSpec)
        self.search_gf.config(relief=tk.SUNKEN)
        ToolTip(self.search_gf, msg.SS_TT_SHOW_BASE)
        self.search_gf.pack(side=tk.LEFT)
        self.search_sp = tk.Button(self.search_frame,
                                   width=3,
                                   text=msg.SS_SPEC,
                                   command=self.toggleMaxSpec)
        self.search_sp.config(relief=tk.SUNKEN)
        ToolTip(self.search_sp, msg.SS_TT_SHOW_SPEC)
        self.search_sp.pack(side=tk.LEFT)
        self.search_box = tk.Entry(self.search_frame, textvariable=self.search)
        ToolTip(self.search_box, msg.SS_TT_SEARCH)
        self.search_box.pack(side=tk.LEFT, fill=tk.X, expand=1)
        self.search_button = tk.Button(
            self.search_frame,
            text=msg.SS_SEARCH,
            command=lambda: self._showSkills(search=True))
        self.search_button.pack(side=tk.RIGHT)
        self.search_frame.pack(fill=tk.X, expand=1)
        self.frame = tk.Frame(self)
        self.scrollbar = tk.Scrollbar(self.frame, orient=tk.VERTICAL)
        self.list_box = tk.Treeview(self.frame)
        self.list_box.bind("<<TreeviewSelect>>", self._selectionChanged)
        self.list_box.config(
            selectmode=tk.EXTENDED,
            yscrollcommand=self.scrollbar.set,
            height=20,
            show="tree",
        )
        self.scrollbar.config(command=self.list_box.yview)
        self.list_box.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
        self.scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
        self.frame.pack(fill=tk.BOTH)

        self.new_skill_name = tk.StringVar()
        self.new_skill_name.set(msg.SS_NEW_SKILL)
        self.new_skill_name.trace(
            "w", lambda name, empty, mode: self._newSkillName())
        self.new_skill_check = False
        self.new_skill_entry = tk.Entry(self,
                                        textvariable=self.new_skill_name,
                                        state=tk.DISABLED)
        self.new_skill_entry.bind("<FocusIn>", self._skillEntryFocus)

        self.new_skill_entry_focus = False
        self.new_skill_entry.pack(fill=tk.X)

        self.add_button_text = tk.StringVar()
        self.add_button = tk.Button(self,
                                    textvariable=self.add_button_text,
                                    command=self.addSkills,
                                    state=tk.DISABLED)
        if self.char.getEditMode() == "generation":
            self.add_button_text.set(msg.SS_ADD_REMOVE_SKILLS)
        else:
            self.add_button_text.set(msg.SS_ADD_SKILLS)
        self.add_button.pack(fill=tk.X)

        self._showSkills()
        self.focus()