class MainWindow(QWidget): def __init__(self): QWidget.__init__(self) self.setWindowTitle('Kunquat Tracker') self._ui_model = None self._main_view = MainView() layout = QVBoxLayout() layout.addWidget(self._main_view) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) self.hide() def set_ui_model(self, ui_model): self._ui_model = ui_model self._main_view.set_ui_model(ui_model) self.update_icon() def update_icon(self): icon_bank = self._ui_model.get_icon_bank() icon_path = icon_bank.get_kunquat_logo_path() icon = QIcon(icon_path) self.setWindowIcon(icon) def unregister_updaters(self): self._main_view.unregister_updaters() def closeEvent(self, event): event.ignore() visibility_manager = self._ui_model.get_visibility_manager() visibility_manager.hide_main()
class MainWindow(QtWidgets.QMainWindow): def __init__(self, config_paths): QtWidgets.QMainWindow.__init__(self) self.setObjectName("MainWindow") self.setWindowTitle("NextVending") self.showFullScreen() #self.resize(550, 800) self.setWindowFlags(self.windowFlags() | QtCore.Qt.FramelessWindowHint) self._config_paths = config_paths # Add shorcut actions self.add_window_actions() # Initialize the main view self.mainView = MainView(self.parse_file('config.json'), self.parse_file('products.json')) self.mainView.signals.log.connect(self.print_log) self.setCentralWidget(self.mainView) # Function to add the respective action shorcuts of the MainWindow def add_window_actions(self): # Close action self.closeAction = QtWidgets.QAction() self.closeAction.setShortcut("Ctrl+Q") self.closeAction.triggered.connect(self.close_app) self.addAction(self.closeAction) # Function to retreive data from an external config file def parse_file(self, conf_fn): if conf_fn not in self._config_paths: self.print_log("Configuration file {} not founded".format( conf_fn.split('/')[-1])) exit() rd = open(self._config_paths[conf_fn], "r+") data = json.load(rd) rd.close() return data # ============================== SLOTS ============================== # Function to print logs in the console with the correct format @QtCore.pyqtSlot(dict) def print_log(self, log_object): print("[{}] {}".format(datetime.now().strftime("%Y/%b/%d:%H:%m:%S"), log_object['msg'])) @QtCore.pyqtSlot() def close_app(self): self.mainView.close_serial() self.close()
class AppController(object): def __init__(self): self.view = MainView() def main(self): self.loop = urwid.MainLoop(self.view, self.view.palette, unhandled_input=self.uninp) self.update() self.loop.run() def update(self, loop=None, user_data=None): self.view.populate() self.alarm = self.loop.set_alarm_in(1.0, self.update) def uninp(self, inp): if inp in ["q", "Q"]: raise urwid.ExitMainLoop()
class AppController(object): def __init__(self): self.view = MainView() def main(self): self.loop = urwid.MainLoop(self.view, self.view.palette, unhandled_input=self.uninp) self.update() self.loop.run() def update(self, loop=None, user_data=None): self.view.populate() self.alarm = self.loop.set_alarm_in(1.0, self.update) def uninp(self, inp): if inp in ['q', 'Q']: raise urwid.ExitMainLoop()
def __init__(self, config_paths): QtWidgets.QMainWindow.__init__(self) self.setObjectName("MainWindow") self.setWindowTitle("NextVending") self.showFullScreen() #self.resize(550, 800) self.setWindowFlags(self.windowFlags() | QtCore.Qt.FramelessWindowHint) self._config_paths = config_paths # Add shorcut actions self.add_window_actions() # Initialize the main view self.mainView = MainView(self.parse_file('config.json'), self.parse_file('products.json')) self.mainView.signals.log.connect(self.print_log) self.setCentralWidget(self.mainView)
def __init__(self): QWidget.__init__(self) self.setWindowTitle('Kunquat Tracker') self._ui_model = None self._main_view = MainView() layout = QVBoxLayout() layout.addWidget(self._main_view) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) self.hide()
async def run(self): self.view = AuthView(self.client, self.stdscr) await self.view.run() self.view = MainView(self.client, self.stdscr) await self.view.run()
# -*- coding: latin-1 -*- from tkinter import Tk from mainview import MainView root = Tk() # Criacao de Main View e rodar usando mainloop MainView(root) root.mainloop()
def __init__(self): self.view = MainView()
class ExpressionDB: def __init__(self): return NotImplemented def get_expression(self, folder, index): return NotImplemented def get_folder(self, index): return NotImplemented # folder iterator # expresion iterator print("initialization....") main = MainView("main") palabras = WordSpellView("palabras", main) opt_palabras = View("opt_palabaras", palabras) frecuentes = View("frecuentes", main) print(opt_palabras) print() print("Starting....\n") view = main while True: for word in view.get_word(): if word: print(word) print() view = view.next_view()