当前位置: 首页>>代码示例>>Python>>正文


Python Market.make_gui方法代码示例

本文整理汇总了Python中market.Market.make_gui方法的典型用法代码示例。如果您正苦于以下问题:Python Market.make_gui方法的具体用法?Python Market.make_gui怎么用?Python Market.make_gui使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在market.Market的用法示例。


在下文中一共展示了Market.make_gui方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from market import Market [as 别名]
# 或者: from market.Market import make_gui [as 别名]
class TravianGui:
    def __init__(self):
        # Gui.__init__(self)
        # gui
        self.root = Tk()
        # compositions
        self.travian = Travian(self.root)
        self.market = Market(self.root, self.travian)
        self.raiding = Raiding(self.root, self.travian)
        self.info = Info(self.root, self.travian)
        # self.mail = Mail()
        # frames
        self.exit_frame = Frame(self.root, bd=5, relief=GROOVE)
        # items
        self.intvars = self.create_intvars()
        self.msg_var = StringVar()
        self.msg_var.set('Messages')
        self.old_news = self.create_news()
        self.news = self.create_news()
        # widgets
        self.buttons = self.create_buttons()
        self.checkboxes = self.create_checkboxes()
        self.messages = self.create_messages()
        # configure gui
        self.config_root()
        self.make_market_frame()
        self.make_raid_frame()
        self.make_info_frame()
        self.make_exit_frame()

    # ============================================
    # region ITEMS
    @staticmethod
    def create_intvars():
        dic = OrderedDict()
        dic['sitter'] = IntVar()
        return dic

    def create_news(self):
        dic = OrderedDict()
        dic['send'] = self.market.send.news
        dic['offer'] = self.market.offer.news
        dic['raid'] = self.raiding.news
        dic['info'] = self.info.news
        return dic

    # ============================================
    # region WIDGETS
    def create_buttons(self):
        dic = OrderedDict()
        dic['restart'] = Button(self.exit_frame, text='Restart', width=self.info.button_size, command=self.restart)
        dic['quit'] = Button(self.exit_frame, text='Exit', width=self.info.button_size, command=self.root.destroy)
        return dic

    def create_checkboxes(self):
        dic = OrderedDict()
        dic['sitter'] = Checkbutton(self.exit_frame, text='sitter', variable=self.intvars['sitter'], command=self.set_sitter)
        return dic

    def create_messages(self):
        dic = OrderedDict()
        dic['terminal'] = Message(self.market.offer.frame, textvar=self.msg_var, bg='bisque3', font='times 12', relief=SUNKEN, aspect=300)
        return dic

    # ============================================
    # region COMMANDS
    def config_root(self):
        self.root.title('Travian Helper')
        self.root.geometry('+600-80')  # 530x400

    def restart(self):
        self.root.destroy()
        python = executable
        execl(python, python, *argv)

    def set_sitter(self):
        is_sitter = bool(self.intvars['sitter'].get())
        return self.travian.sitter_mode(is_sitter)

    def message_handler(self):
        self.news = self.create_news()
        for key, value in self.news.iteritems():
            if value != self.old_news[key]:
                self.msg_var.set(value)
                self.old_news[key] = value
        self.messages['terminal'].after(100, self.message_handler)
    #  endregion

    # ============================================
    # region FRAMES AND PACKING
    def make_market_frame(self):
        self.market.frame.grid()
        self.market.make_gui()
        self.messages['terminal'].grid(row=6, columnspan=5, sticky='NEWS', pady=2, padx=2)
        self.market.offer.frame.grid_rowconfigure(6, weight=1)

    def make_raid_frame(self):
        self.raiding.frame.grid(row=0, column=1, sticky='NEWS')
        self.raiding.frame.grid_rowconfigure(1, weight=1)
        self.raiding.make_gui()
#.........这里部分代码省略.........
开发者ID:michareichmann,项目名称:Travian,代码行数:103,代码来源:travian-gui.py


注:本文中的market.Market.make_gui方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。