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


Python Model.start方法代码示例

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


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

示例1: Application

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import start [as 别名]
class Application(ttk.Frame):
        
    def __init__(self,parent,**kwargs):
        # Init
        self.parent = parent
        ttk.Frame.__init__(self,parent,**kwargs)
        # Init configuration
        ttk.Style().configure("BW.TLabel")
        ttk.Style().configure("BW.TButton")
        
        # Create Model
        self.model = Model()

        # COM Frame
        self.frame_com_ports = COM_Frame(self,self.model,relief=Tk.GROOVE)
        self.frame_com_ports.grid(column=0,row=0,sticky='NSEW',pady=2,padx=5)

        # Logger frame
        self.frame_logger = Logger_Frame(self,self.model,bd=2,relief=Tk.GROOVE)
        self.frame_logger.grid(column=0,row=1,sticky='NSEW',pady=2,padx=5)

        # Graph 1 frame
        self.frame_graph1 = Plot2D_Frame(self,self.model,self.parent,bd=2,relief=Tk.GROOVE)
        self.frame_graph1.grid(column=1,row=0,sticky='EW',pady=2,padx=0,rowspan=2)

        # Graph 2 frame
        self.frame_graph2 = Plot2D_Frame(self,self.model,self.parent,bd=2,relief=Tk.GROOVE)
        self.frame_graph2.grid(column=2,row=0,sticky='EW',pady=2,padx=0,rowspan=2)

        # Quit button
        self.bouton_quitter = Tk.Button(self, text="QUITTER",command = self.stop)
        self.bouton_quitter.grid(column=0,row=2,sticky='EW',pady=2,padx=5)

        self.model.start()

    def stop(self):
        self.model.stop()
        
        if self.model.isAlive():
            self.model.join(0.1)
            
        if self.model.isAlive():
            self.model.join(1)

        if self.model.isAlive():
            print("--- Model thread not properly joined.")
            
        self.parent.destroy()
开发者ID:DanFaudemer,项目名称:TFC,代码行数:50,代码来源:GUI.py

示例2: fake_data_received

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import start [as 别名]
from pubsub import pub
from SerialPort import SerialPort
from threading import Timer
import struct as struct
import time
from VariableManager import VariableManager

# NOTE : Remove comments in front of prints in VariableManager.py line 89 & 94

def fake_data_received(var_id):
    d = dict()
    pub.sendMessage('var_value_update',varid=var_id,data=d)

model = Model()
mgr = VariableManager(model)
model.start()

# Todo : send a fake table
# Otherwise test fully functionnal

# Normal sequence (start 2 -> stop 2)
pub.sendMessage('using_var',varid=2)
time.sleep(1.0)
fake_data_received(2)
pub.sendMessage('stop_using_var',varid=2)

time.sleep(1.0)

# Immediate erase sequence
# (If erase happens before 500 ms
#  no start to avoid querying variables to quickly to the MCU)
开发者ID:DanFaudemer,项目名称:TFC,代码行数:33,代码来源:UnitTest_VariableManager.py

示例3: Application

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import start [as 别名]
class Application(ttk.Frame):
        
    def __init__(self,parent,**kwargs):
        # Init
        self.parent = parent
        ttk.Frame.__init__(self,parent,**kwargs)
        # Init configuration
        ttk.Style().configure("BW.TLabel")
        ttk.Style().configure("BW.TButton")
        
        self.grid(row=0,column=0,sticky="WENS")
        
        # Create Model
        self.model = Model()

        # COM Frame
        self.frame_com_ports = COM_Frame(self,self.model,relief=Tk.GROOVE)
        self.frame_com_ports.grid(column=0,row=0,sticky='NSEW',pady=2,padx=5)

        # Logger frame
        self.frame_logger = Logger_Frame(self,self.model,bd=2,relief=Tk.GROOVE)
        self.frame_logger.grid(column=0,row=1,sticky='NSEW',pady=2,padx=5)

        # Graph 1 frame
       # self.frame_graph1 = Plot2D_Frame(self,self.model,self.parent,bd=2,relief=Tk.GROOVE)
       # self.frame_graph1.grid(column=1,row=0,sticky='EW',pady=2,padx=0,rowspan=2)

        # Graph 2 frame
       # self.frame_graph2 = Plot2D_Frame(self,self.model,self.parent,bd=2,relief=Tk.GROOVE)
       # self.frame_graph2.grid(column=2,row=0,sticky='EW',pady=2,padx=0,rowspan=2)
        
        
        # Quit button
        self.bouton_quitter = Tk.Button(self, text="QUITTER",command = self.stop)
        self.bouton_quitter.grid(column=0,row=2,sticky='EW',pady=2,padx=5)

        #redimensionnement
        self.parent.grid_columnconfigure(0,weight=1)
        self.parent.grid_rowconfigure(0,weight=1)
        self.grid_rowconfigure(1,weight=2)
        self.parent.minsize(width=350, height=500)

        
        self.model.start()

        # Subsciptions
        pub.subscribe(self.listener_valPlot,"plot_var")
        
    def stop(self):
        self.model.stop()
        
        if self.model.isAlive():
            self.model.join(0.1)
            
        if self.model.isAlive():
            self.model.join(1)

        if self.model.isAlive():
            print("--- Model thread not properly joined.")
            
        self.parent.destroy()

    def listener_valPlot(self):
        self.plot = Tk.Toplevel() 
        self.Plot_frm = Plot2D_Frame(self.plot,self.model, self.plot)
        self.plot.minsize(width=300, height=200)
        try: 
            self.frame_logger.variable_selected(None)
            self.Plot_frm.add_var_to_plot()
        except:
            print("err1")
开发者ID:DanFaudemer,项目名称:TFC,代码行数:73,代码来源:GUI.py


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