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


Python Settings.set_auto_reconnect方法代码示例

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

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

示例1: __init__

# 需要导入模块: import Settings [as 别名]
# 或者: from Settings import set_auto_reconnect [as 别名]
class App:
    def __init__(self, master):
        self._master = master
        self._master.title("ArduinoMonitor")
        
        self.refresh_time = 100
        
        self.state_hold = False
        
        self._status = {}
        
        self.info_message = None
        self._serialdevicevar = StringVar()
        self._baudratevar = StringVar()
        self._autoreconnectvar = BooleanVar()
        
        self.serialsettingsframe = Frame(self._master)
        
        Label(self.serialsettingsframe, text='Serial device:').pack(side=LEFT)
        
        self.serialdeviceoptionmenu = OptionMenu(self.serialsettingsframe, self._serialdevicevar, (''))
        self.serialdeviceoptionmenu.pack(side=LEFT)
        self.serialdeviceoptionmenu.bind('<Button-1>', self.reloadserialdevices)
        self._serialdevicevar.trace('w', self.serialdeviceoptionmenu_changed)
        
        Label(self.serialsettingsframe, text='Baudrate:').pack(side=LEFT)
        self.baudratoptionmenu = OptionMenu(self.serialsettingsframe, self._baudratevar, '300', '600', '1200', '2400', '4800', '9600', '14400', '19200', '28800', '38400', '57600', '115200')
        self._baudratevar.trace('w', self.baudratoptionmenu_changed)
        self.baudratoptionmenu.pack(side=LEFT)
        
        self.autoreconnectcheckbox = Checkbutton(master=self.serialsettingsframe, text="Auto reconnect", variable=self._autoreconnectvar, command=self.autoreconnectcheckbox_changed)
        self.autoreconnectcheckbox.select()
        self.autoreconnectcheckbox.pack(side=LEFT)
        
        self.connectbutton = Button(master=self.serialsettingsframe, text='Connect', command=self.connectbutton_clicked)
        self.connectbutton.pack(side=LEFT)
        
        self.controlsframe = Frame(self.serialsettingsframe)
        
        self.holdbutton = Button(master=self.controlsframe, text='Hold', command=self.holdbuttonclicked)
        self.holdbutton.pack(side=LEFT)
        
        self.hidedatabutton = Button(master=self.controlsframe, text='Show Data', command=self.hidedatabuttonclicked)
        self.hidedatabutton.pack(side=LEFT)
        
        self.configbutton = Button(master=self.controlsframe, text='Config Graphs', command=self.configbutton_clicked)
        self.configbutton.pack(side=LEFT)
        
        self.exportbutton = Button(master=self.controlsframe, text='Export', command=self.export_data)
        self.exportbutton.pack(side=LEFT)
        
        self.importbutton = Button(master=self.controlsframe, text='Import', command=self.import_data)
        self.importbutton.pack(side=LEFT)
        
        self.controlsframe.pack(side=RIGHT, fill=X)
        
        self.serialsettingsframe.grid(column=0, row=0, columnspan=2, sticky=NSEW)
        
        self.plotframe = PlotFrame(self._master)
        self.plotframe.grid(row=1, column=0, sticky=NSEW)
        
        self.communicationframe = CommunicationFrame(self._master)
        self.communicationframe.grid(column=1, row=1, sticky=NSEW)
        
        self.serial_communication = SerialCommunication(self._autoreconnectvar.get(), 1)
        self.communicationframe.serial_send = self.serial_communication.send
 
        self._master.columnconfigure(0, weight=8)
        self._master.columnconfigure(1, weight=2)
        self._master.rowconfigure(0, weight=0)
        self._master.rowconfigure(1, weight=1)
        
        
        self.settings = Settings()
        self._serialdevicevar.set(self.settings.get_serial_device())
        self._baudratevar.set(self.settings.get_baud_rate())
        self._autoreconnectvar.set(self.settings.get_auto_reconnect())
        for m in reversed(self.settings.get_history()):
            self.communicationframe.add_to_history(m)

        self.reloadserialdevices()
        
        self.__file_options = {}
        self.__file_options['defaultextension'] = '.aml'
        self.__file_options['filetypes'] = [('ArduinoMonitor-Log', '.aml')]
        self.__file_options['initialdir'] = self.settings.get_last_dir()
        self.__file_options['parent'] = self._master
        
        self.__update()
    
    def finish(self):
        self.settings.set_serial_device(self._serialdevicevar.get())
        self.settings.set_baud_rate(self._baudratevar.get())
        self.settings.set_auto_reconnect(self._autoreconnectvar.get())
        self.settings.set_history(self.communicationframe.get_history())
        self.settings.write()
    
    def export_data(self):
        fileh = tkFileDialog.asksaveasfile(mode='w', title="Export ArduinoMonitor-Log", **self.__file_options)
        
#.........这里部分代码省略.........
开发者ID:stefanhoelzl,项目名称:ArduinoMonitor,代码行数:103,代码来源:ArduinoMonitor.py



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