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


Python Preferences.stop方法代码示例

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


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

示例1: App

# 需要导入模块: from preferences import Preferences [as 别名]
# 或者: from preferences.Preferences import stop [as 别名]
class App(tk.Tk):
    def __init__(self, *args, **kwargs):
        super(App, self).__init__(*args, **kwargs)

        self.i = 0
        self.o = 0
        self.__flush_id = 0
        self.preferences = Preferences(on_load=self.configure)


        # always on top
        self.wm_attributes("-topmost", 1)
        # transparency
        self.attributes("-alpha", 0.85)

        self.title("Teststep")
        self.iconbitmap("icons\\accept.ico")

        status_frame = ttk.Frame(self)

        status_frame.pack(side=tk.BOTTOM, fill=tk.X)

        ttk.Sizegrip(status_frame).pack(side=tk.RIGHT)

        measureSystem = tk.StringVar()

        def changed():
            print('OHO!', measureSystem.get())


        check = ttk.Checkbutton(status_frame, text='Always on top', 
                                command=changed, variable=measureSystem, 
                                onvalue='metric', offvalue='imperial')
        check.pack(side=tk.RIGHT)

        progress_bar = ProgressBar(status_frame, values=[0.93, 0.75], height=5)
        progress_bar.pack(side=tk.BOTTOM, expand=True, fill=tk.BOTH)

        frame_buttons = tk.Frame(self, pady=3)

        button_passed = tk.Button(frame_buttons, text="Passed", height=1, 
                                  command=self.click)
        button_passed.pack(expand=True, fill=tk.X, side=tk.LEFT, padx=3)
        button_failed = tk.Button(frame_buttons, text="Failed", width=12, 
                                  height=1, command=self.click)
        button_failed.pack(expand=True, fill=tk.X, side=tk.LEFT, padx=3)
        button_blocked = tk.Button(frame_buttons, text="Blocked", width=12, 
                                   height=1, command=self.click)
        button_blocked.pack(expand=True, fill=tk.X, side=tk.LEFT, padx=3)

        frame_buttons.pack(side=tk.BOTTOM, expand=True, fill=tk.X)

        self.task_comment = tk.PanedWindow(self, orient=tk.VERTICAL, sashpad=3, 
                                           sashwidth=3, sashrelief=tk.RAISED)
        self.task_comment.pack(expand=True, fill=tk.BOTH, pady=3)

        self.task = ScrolledText(self.task_comment, 'Task', width=80, 
                                 font=("Calibri", 14), wrap=tk.NONE)
        self.task_comment.add(self.task.frame, stretch='always')

        add_text_example(self.task)
        
        comment = ScrolledText(self, 'Comment', width=80, height=5, 
                               font=("Calibri", 14), wrap=tk.NONE)
        self.task_comment.add(comment.frame, stretch='always')

        self.bind("<Configure>", self.on_configure)
        self.task.frame.bind("<Configure>", self.on_configure)


    def test(self):
        self.preferences.flush()
        print('call', self.i)
        self.i += 1

    def configure(self, preferences):
        logger.debug("New configuration %d", self.o)
        self.o += 1

    def on_configure(self, event):
        self.after_cancel(self.__flush_id)

        if event.widget is self:
            self.preferences['position'] = {'x': event.x, 'y': event.y}
            self.preferences['size'] = {'w': event.width, 'h': event.height}
        elif event.widget is self.task.frame:
            __, self.preferences['sash_position'] = self.task_comment.sash_coord(0)

        self.after_cancel(self.__flush_id)
        self.__flush_id = self.after_idle(self.test)

    def destroy(self):
        logger.debug('Destroy window')
        super(App, self).destroy()
        self.preferences.stop()

      
    def click(self):
        icons = [os.path.join('icons', f) 
                 for f in os.listdir('icons') 
#.........这里部分代码省略.........
开发者ID:zdxerr,项目名称:testrun,代码行数:103,代码来源:gui.py


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