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


Python Screen.pack方法代码示例

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


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

示例1: Oscilloscope

# 需要导入模块: from screen import Screen [as 别名]
# 或者: from screen.Screen import pack [as 别名]
class Oscilloscope(Frame):
    """ Oscilloscope 

    time : valeur de la base de temps
    signaux : liste de couples, (temps,elongation) ou (elongation X, elongation Y)  de signaux
    screen : ecran de visualisation de signaux
    time_control : controle de la base de temps
    signal_control : controle d'un signal
    """
    def __init__(self, parent=None, width=800, height=800):
        """ initialisation

        parent : une application
        width,height : dimension de l'oscilloscpe
        """
        Frame.__init__(self)
        self.master.title("Oscilloscope")
        # Modele
        self.time = 0
        self.signal = None
        # Vues
        self.menuBar         = MenuBar(parent=self)
        self.screen          = Screen(parent=self)
        self.frame = Frame(master=self)
        # Controleurs
        self.time_control = TimeBase(parent=self)
        self.signal_controlX = Generator(parent=self, name="X", color="red")
        self.signal_controlY = Generator(parent=self, name="Y", color="blue")
        # Affichage Vues, Controleurs
        self.menuBar.pack()
        self.screen.pack()

        self.signal_controlX.pack(side="left")
        self.signal_controlY.pack(side="left")
        self.time_control.pack()

        self.configure(width=width, height=height)

    def get_time(self):
        """valeur courante de la base de temps."""
        return self.time_control.get_time()

    def update_time(self, time):
        """demande de calcul de signal si modification de la base de temps"""
        if self.time != time:
            self.time = time
            self.signal_controlX.update_signal(None)
            self.signal_controlY.update_signal(None)

    def set_signal(self, name="X", signal=None):
        """ demande d'affichage de signal

        name : nom de la courbe (X,Y, X-Y)
        signal : liste des couples (temps,elongation) ou (elongation X, elongation Y)
        """
        print("Base de Temps :", self.get_time())
        msdiv = self.get_time()
        if signal :
            signal = signal[0:(len(signal)/msdiv) + 1]
            signal = map(lambda (x, y): (x*msdiv, y), signal)
            self.screen.plot_signal(name, signal)
        return signal
开发者ID:Akanoa,项目名称:CAI2014,代码行数:64,代码来源:oscilloscope.py

示例2: Oscilloscope

# 需要导入模块: from screen import Screen [as 别名]
# 或者: from screen.Screen import pack [as 别名]
class Oscilloscope(Frame):
    """ 
    Modele d'Oscilloscope 

    time : valeur de la base de temps
    signal : liste de couples, (temps,elongation) ou (elongation X, elongation Y)  de signaux
    view : visualisation de signaux
    control_X : controle d'un signal
    control_time : controle de la base de temps
    """
    def __init__(self, parent=None, width=800, height=800):
        """ 
        Initialisation

        parent : une application
        width,height : dimension de l'oscilloscpe
        """
        Frame.__init__(self)
        self.master.title("Oscilloscope - Diquélou - Toscer")

        # doit-on afficher la courbe de lissajoux
        self.drawXY = IntVar()
        
        # Modele
        self.time = 0
        # gestion des signaux X et Y
        self.signal_X   = None
        self.signal_Y   = None
        self.signal_XY = None
        # Vues
        self.view = Screen(parent=self)
        self.lissajoux = Screen(parent= self)
        # Controleurs
        self.control_time = TimeBase(parent=self)
        self.control_X = Generator(self,'X')
        self.control_Y = Generator(self, 'Y')



        # menu
        menuBar = MenuBar(self)
        menuBar.pack(fill="x");

        # Affichage Vues, Controleurs
        self.view.pack(fill="both")

        self.control_time.pack(side="left", fill="y")
     
        self.control_X.pack(side="left",fill="y")

        self.lissajoux.pack(fill="both", side="left", expand=1)

        self.control_Y.pack(side="right", fill="both")

        self.configure(width=width, height=height)
        self.master.protocol("WM_DELETE_WINDOW", self.quitter)

        
    def get_time(self):
        """
        recuperer la valeur courante de la base de temps
        """
        return self.control_time.get_time()

    def update_time(self, time):
        """
        calcul de signal si modification de la base de temps

        time : nouvelle valeur de la base de temps
        """
        if self.time != time:
            self.time = time
            self.control_X.update_signal(None)
            self.control_Y.update_signal(None)
            

    def plot_all(self):
        """
        affiche tous les signaux
        """
        self.update_view('X',self.control_X.signal)
        self.update_view('Y',self.control_Y.signal)
        self.update_view('XY',self.control_X.signal)

    def update_view(self, name="X", signal=None):
        """ demande d'affichage de signal

        name : nom de la courbe (X,Y, X-Y)
        signal : liste des couples (temps,elongation) ou (elongation X, elongation Y)
        """
        print("Base de Temps :", self.get_time())
        msdiv = self.get_time()
        if signal :
            if name!='XY':
                signal = signal[0:(len(signal)/msdiv) + 1]
                signal = map(lambda (x, y): (x*msdiv, y), signal)
                
                self.view.plot_signal(name, signal)

            else:
#.........这里部分代码省略.........
开发者ID:holiday2018,项目名称:python_oscilloscope,代码行数:103,代码来源:oscilloscope.py


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