def __init__(self): super().__init__() self._btn = QPushButton("Toggle", self) self._procStateText = QLabel("Unknown Status", self) self._autoDetectCB = QCheckBox("Auto detect", self) self._msg = QLabel("msg", self) self._controller = Controller(self.set_proc_state, self.msg) self.init_gui()
def __init__(self, logger, threadPool, module_manager, settings, soundsink, ev_quit, model): self.soundsink = soundsink Viewer.__init__(self) Controller.__init__(self, logger, threadPool, module_manager, settings, ev_quit, model)
def __init__(self): super().__init__(None, style=_style) self.SetTitle("AutoPauseMC") self.SetIcon(wx.Icon("8.ico", wx.BITMAP_TYPE_ICO)) self.SetSize(300, 110) self.SetPosition((300, 300)) self._button = wx.Button(self, label="Toggle", pos=(7, 7), size=(80, 30)) self._checkBox = wx.CheckBox(self, label="AutoDetect", pos=(7, 44), size=(80, 30)) self._status = wx.StaticText(self, pos=(110, 14), size=(240, 10)) self._msg = wx.StaticText(self, pos=(110, 44), size=(240, 10)) self._controller = Controller(GUI_msg=self.msg, GUI_set_status=self.set_status) self.init() self.Show()
class GUI(QWidget): def __init__(self): super().__init__() self._btn = QPushButton("Toggle", self) self._procStateText = QLabel("Unknown Status", self) self._autoDetectCB = QCheckBox("Auto detect", self) self._msg = QLabel("msg", self) self._controller = Controller(self.set_proc_state, self.msg) self.init_gui() def set_proc_state(self, state): pst = self._procStateText pst.setText(state) pst.adjustSize() def msg(self, message): msg = self._msg msg.setText(message) msg.adjustSize() def init_gui(self): self.resize(350, 100) self.move(300, 300) self.setWindowTitle("AutoPauseMC") self.setFixedSize(self.size()) self.init_base_layout() self.show() def init_base_layout(self): btn = self._btn pst = self._procStateText chb = self._autoDetectCB msg = self._msg pst.adjustSize() btn.adjustSize() chb.adjustSize() msg.adjustSize() pst.move(200, 20) msg.move(200, 60) btn.move(15, 15) chb.move(15, 60) btn.clicked.connect(self.on_click) chb.toggled.connect(self.on_toggle) def closeEvent(self, QCloseEvent): self._controller.stop_threads() @pyqtSlot(name="btn onClick") def on_click(self): print("button pressed") self._controller.on_click() @pyqtSlot(name="chb onToggle") def on_toggle(self): print("checkBox toggled") self._controller.on_cb_toggled(self._autoDetectCB.isChecked())
class wxGUI(wx.Frame): def __init__(self): super().__init__(None, style=_style) self.SetTitle("AutoPauseMC") self.SetIcon(wx.Icon("8.ico", wx.BITMAP_TYPE_ICO)) self.SetSize(300, 110) self.SetPosition((300, 300)) self._button = wx.Button(self, label="Toggle", pos=(7, 7), size=(80, 30)) self._checkBox = wx.CheckBox(self, label="AutoDetect", pos=(7, 44), size=(80, 30)) self._status = wx.StaticText(self, pos=(110, 14), size=(240, 10)) self._msg = wx.StaticText(self, pos=(110, 44), size=(240, 10)) self._controller = Controller(GUI_msg=self.msg, GUI_set_status=self.set_status) self.init() self.Show() def msg(self, msg): self._msg.SetLabelText(msg) def set_status(self, status): self._status.SetLabelText(status) def init(self): self._button.Bind(wx.EVT_BUTTON, self.on_click) self._checkBox.Bind(wx.EVT_CHECKBOX, self.on_cb_toggle) self.set_status("Unknown status.") self.msg("Waiting...") def on_click(self, evt): if globalVar.get_value("debug", False): print("[DEBUG]wxGUI=>on_click: Button clicked: " + str(evt)) self._controller.on_click() def on_cb_toggle(self, evt): if globalVar.get_value("debug", False): print("[DEBUG]wxGUI=>on_cb_toggle: CB Toggled: %s,%s" % (str(self._checkBox.IsChecked()), str(evt))) self._controller.on_cb_toggled(self._checkBox.IsChecked()) def stop_controller(self): self._controller.stop_threads()
def main(): Controller()
#!/usr/bin/env python # -*- coding: utf-8 -*- """ This program is dedicated to the public domain under the CC0 license. """ import logging import telegram from telegram.error import NetworkError, Unauthorized from time import sleep from threading import Thread from Control import Controller # from telegram import (ReplyKeyboardMarkup, ReplyKeyboardRemove, MessageEntity) TOKEN = '' # Your token for your bot. controller = Controller() class Bot: def __init__(self): self.update_id = None self.bot = telegram.Bot(TOKEN) def handler(self): pass def echo(self): for update in self.bot.get_updates(offset=self.update_id, timeout=10): self.update_id = update.update_id + 1