def main(): app = QtGui.QApplication(sys.argv) signal.signal(signal.SIGINT, signal.SIG_DFL) operation_queue = GuiOperationQueue() library = Library() settings = UserSettings(operation_queue, library) player = Player() if len(sys.argv) > 1: argsongs = argParser.get_queue(sys.argv) player.setQueue(SongQueue(argsongs)) player.play() if sys.platform == 'win32': import ctypes myappid = 'Lune.Atlas' ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) view = MainWindow(library, player, settings, operation_queue) view.show() app.exec_()
class noteController: def __init__(self): super().__init__() self.model = window_model.windowModel() self.view = MainWindow() self.view.updateScreen(self.model.readDB()) self.__addEventHandlers() def __addEventHandlers(self): self.view.notes.textChanged.connect(lambda: self.__getNotes()) # self.view.notes.textChanged.connect(lambda: self.view.addPointer()) # self.view.notes.keyPressEvent(self) def __getNotes(self): notes = self.view.getNotes() self.model.uploadToDB(notes)
def main(): app = QtGui.QApplication(sys.argv) signal.signal(signal.SIGINT, signal.SIG_DFL) result_queue = multiprocessing.Queue() library = Library() settings = UserSettings(result_queue) song_queue = SongQueue() #this should not be here tho argsongs = None if len(sys.argv) > 1: argsongs = argParser.get_queue(sys.argv) if argsongs: song_queue.add_last(argsongs) player = Player() player.set_queue(song_queue) if song_queue: player.play() if sys.platform == 'win32': import ctypes myappid = 'Lune.Atlas' ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) library.load() view = MainWindow(library, player, settings, result_queue) view.show() app.exec_()
import tkinter as tk from views.main_window import MainWindow if __name__ == '__main__': root = tk.Tk() app = MainWindow(root) root.mainloop()
LOG_LEVEL_WORK = logging.ERROR elif str(LOG_LEVEL).upper() == 'CRITICAL': LOG_LEVEL_WORK = logging.CRITICAL logger = logging.getLogger('main') if WRITE_LOG_TO_FILE: file_log = logging.FileHandler( f'log_{datetime.now().strftime("%m%d%Y%H%M%S")}.txt', mode='a') console_out = logging.StreamHandler() logging.basicConfig(handlers=(file_log, console_out), format=LOG_FORMAT, level=LOG_LEVEL_WORK, datefmt=date_format) else: logging.basicConfig(format=LOG_FORMAT, level=LOG_LEVEL, datefmt='%d/%m/%y %H:%M:%S') if platform == "linux" or platform == "linux2" or platform == "darwin": _path = os.path.abspath(__file__) os.system(f'find {_path}' + ' -type f -name "log_*" -mtime +168 -exec rm -rf {} \;') logger.info('Удалим логи старше недели') else: logger.info('Не могу удалить логи, если мы не в unix') app = QApplication(sys.argv) window = MainWindow() window.show() sys.exit(app.exec())
def __init__(self): super().__init__() self.model = window_model.windowModel() self.view = MainWindow() self.view.updateScreen(self.model.readDB()) self.__addEventHandlers()
def ShowMainWindow(self): self.main_window = MainWindow(self.mdi) self.main_window.showMaximized()
class MDIWindow(QMainWindow): def __init__(self): super().__init__() self.mdi = QMdiArea() self.setCentralWidget(self.mdi) menu = self.menuBar() apartments = menu.addAction("Apartments") apartments.triggered.connect(self.ShowApartments) reservations = menu.addMenu("Bookings") reservations_add = reservations.addAction("Add") reservations_add.triggered.connect(self.AddReservations) reservations_view = reservations.addAction("View") reservations_view.triggered.connect(self.ShowReservations) users = menu.addAction("Guests") users.triggered.connect(self.ShowUsers) help = menu.addAction("Help") help.triggered.connect(self.ShowHelp) self.setWindowTitle("Hotel app") self.ShowMainWindow() @Slot() def ShowMainWindow(self): self.main_window = MainWindow(self.mdi) self.main_window.showMaximized() @Slot() def AddReservations(self): print("reservations add") self.closeMainWindow() add_reservations_window = AddReservationWindow(self.mdi) add_reservations_window.destroyed.connect(self.ShowMainWindow) @Slot() def ShowReservations(self): print("reservations view") self.closeMainWindow() reservations_window = ReservationsWindow(self.mdi) reservations_window.destroyed.connect(self.ShowMainWindow) @Slot() def ShowApartments(self, p): #add singleton self.closeMainWindow() apartments_window = ApartmentsWindow(self.mdi) apartments_window.destroyed.connect(self.ShowMainWindow) @Slot() def ShowUsers(self): print("Show users") self.closeMainWindow() guests_window = GuestsWindow(self.mdi) guests_window.destroyed.connect(self.ShowMainWindow) @Slot() def ShowHelp(self): msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText("This is help") msg.exec_() print("Help") def closeMainWindow(self): if self.main_window: self.main_window.close() self.main_window = None
def do_activate(self): MainWindow(self).show_all()
def initView(self): # Create main Window self.frame = MainWindow(None) self.frame.Maximize(True) self.frame.Show(True) # Create Image self.image = Image() # Adjust Panel Size frame_width = self.frame.GetSize().GetWidth() self.frame.panel_initial.setSplitterPanelSize((frame_width*2)/3) self.frame.panel_initial.setSplitterImageSize(frame_width/6) # Create local references to components self.imageTree = self.frame.panel_initial.image.list_files self.textOutput = self.frame.panel_initial.parameters.outputBrowser.fileText # -------------------------------------------------------- # ----------------- Set Binds To Frame ------------------ # -------------------------------------------------------- # Close Frame Bind self.frame.Bind(wx.EVT_CLOSE, self.onExit) # -------------------------------------------------------- # ----------------- Set Binds To MenuBar ---------------- # -------------------------------------------------------- # Open Bind self.frame.Bind(wx.EVT_MENU, self.onOpen, self.frame.fMenuOpen) # Quit Bind self.frame.Bind(wx.EVT_MENU, self.onExit, self.frame.fMenuExit) # Copy Bind self.frame.Bind(wx.EVT_MENU, self.onCopy, self.frame.eMenuCopy) # Cut Bind self.frame.Bind(wx.EVT_MENU, self.onCut, self.frame.eMenuCut) # Paste Bind self.frame.Bind(wx.EVT_MENU, self.onPaste, self.frame.eMenuPaste) # Help Bind self.frame.Bind(wx.EVT_MENU, self.onHelp, self.frame.hMenuHelp) # About Bind self.frame.Bind(wx.EVT_MENU, self.onAbout, self.frame.hMenuAbout) # -------------------------------------------------------- # ----------------- Set Binds To Toolbar ---------------- # -------------------------------------------------------- # open Bind self.frame.Bind(wx.EVT_TOOL, self.onOpen, self.frame.tool_open) # Save Bind self.frame.Bind(wx.EVT_TOOL, self.onSave, self.frame.tool_save) # Start Bind self.frame.Bind(wx.EVT_TOOL, self.onStart, self.frame.tool_start) # Stop Bind self.frame.Bind(wx.EVT_TOOL, self.onStop, self.frame.tool_stop) # Exit Bind self.frame.Bind(wx.EVT_TOOL, self.onExit, self.frame.tool_exit) # -------------------------------------------------------- # ------ Set Binds To Parameters Panel Buttons ---------- # -------------------------------------------------------- # Start Bind self.frame.Bind(wx.EVT_BUTTON, self.onOutput, self.frame.panel_initial.getOutputButton()) # Stop Bind self.frame.Bind(wx.EVT_BUTTON, self.onStart, self.frame.panel_initial.getStartButton()) # -------------------------------------------------------- # ---------- Set Binds To Image Panel Buttons ----------- # -------------------------------------------------------- # Add Folder Bind self.frame.Bind(wx.EVT_BUTTON, self.onAddFolder, self.frame.panel_initial.getAddFolderButton()) # Add File Bind self.frame.Bind(wx.EVT_BUTTON, self.onAddFile, self.frame.panel_initial.getAddFileButton()) # Remove Bind self.frame.Bind(wx.EVT_BUTTON, self.onRemove, self.frame.panel_initial.getRemoveButton()) # -------------------------------------------------------- # -------------- Set Binds To Image Tree ---------------- # -------------------------------------------------------- self.frame.Bind(wx.EVT_TREE_SEL_CHANGED, self.onSelChanged, self.imageTree)
class MainWindowControl: """ Controller for the Application """ def __init__(self): self.initView() def initView(self): # Create main Window self.frame = MainWindow(None) self.frame.Maximize(True) self.frame.Show(True) # Create Image self.image = Image() # Adjust Panel Size frame_width = self.frame.GetSize().GetWidth() self.frame.panel_initial.setSplitterPanelSize((frame_width*2)/3) self.frame.panel_initial.setSplitterImageSize(frame_width/6) # Create local references to components self.imageTree = self.frame.panel_initial.image.list_files self.textOutput = self.frame.panel_initial.parameters.outputBrowser.fileText # -------------------------------------------------------- # ----------------- Set Binds To Frame ------------------ # -------------------------------------------------------- # Close Frame Bind self.frame.Bind(wx.EVT_CLOSE, self.onExit) # -------------------------------------------------------- # ----------------- Set Binds To MenuBar ---------------- # -------------------------------------------------------- # Open Bind self.frame.Bind(wx.EVT_MENU, self.onOpen, self.frame.fMenuOpen) # Quit Bind self.frame.Bind(wx.EVT_MENU, self.onExit, self.frame.fMenuExit) # Copy Bind self.frame.Bind(wx.EVT_MENU, self.onCopy, self.frame.eMenuCopy) # Cut Bind self.frame.Bind(wx.EVT_MENU, self.onCut, self.frame.eMenuCut) # Paste Bind self.frame.Bind(wx.EVT_MENU, self.onPaste, self.frame.eMenuPaste) # Help Bind self.frame.Bind(wx.EVT_MENU, self.onHelp, self.frame.hMenuHelp) # About Bind self.frame.Bind(wx.EVT_MENU, self.onAbout, self.frame.hMenuAbout) # -------------------------------------------------------- # ----------------- Set Binds To Toolbar ---------------- # -------------------------------------------------------- # open Bind self.frame.Bind(wx.EVT_TOOL, self.onOpen, self.frame.tool_open) # Save Bind self.frame.Bind(wx.EVT_TOOL, self.onSave, self.frame.tool_save) # Start Bind self.frame.Bind(wx.EVT_TOOL, self.onStart, self.frame.tool_start) # Stop Bind self.frame.Bind(wx.EVT_TOOL, self.onStop, self.frame.tool_stop) # Exit Bind self.frame.Bind(wx.EVT_TOOL, self.onExit, self.frame.tool_exit) # -------------------------------------------------------- # ------ Set Binds To Parameters Panel Buttons ---------- # -------------------------------------------------------- # Start Bind self.frame.Bind(wx.EVT_BUTTON, self.onOutput, self.frame.panel_initial.getOutputButton()) # Stop Bind self.frame.Bind(wx.EVT_BUTTON, self.onStart, self.frame.panel_initial.getStartButton()) # -------------------------------------------------------- # ---------- Set Binds To Image Panel Buttons ----------- # -------------------------------------------------------- # Add Folder Bind self.frame.Bind(wx.EVT_BUTTON, self.onAddFolder, self.frame.panel_initial.getAddFolderButton()) # Add File Bind self.frame.Bind(wx.EVT_BUTTON, self.onAddFile, self.frame.panel_initial.getAddFileButton()) # Remove Bind self.frame.Bind(wx.EVT_BUTTON, self.onRemove, self.frame.panel_initial.getRemoveButton()) # -------------------------------------------------------- # -------------- Set Binds To Image Tree ---------------- # -------------------------------------------------------- self.frame.Bind(wx.EVT_TREE_SEL_CHANGED, self.onSelChanged, self.imageTree) # -------------------------------------------------------- # ----------------- Set Binds Functions ----------------- # -------------------------------------------------------- def onOpen(self, event): wx.MessageBox('Open Information', 'Info', wx.OK | wx.ICON_INFORMATION) # Exit Function (Load Question Message to Confirm Close Application) def onExit(self, event): self.frame.Destroy() #dialog_exit = wx.MessageDialog(self.frame, u'Desea salir de la aplicación', 'Salir') #if dialog_exit.ShowModal() == wx.ID_OK: # self.frame.Destroy() def onCopy(self, evente): wx.MessageBox('Copy Information', 'Info', wx.OK | wx.ICON_INFORMATION) def onCut(self, event): wx.MessageBox('Cut Information', 'Info', wx.OK | wx.ICON_INFORMATION) def onPaste(self, event): wx.MessageBox('Paste Information', 'Info', wx.OK | wx.ICON_INFORMATION) def onHelp(self, event): wx.MessageBox('Help Information', 'Info', wx.OK | wx.ICON_INFORMATION) def onAbout(self, event): wx.MessageBox('About Information', 'Info', wx.OK | wx.ICON_INFORMATION) def onSave(self, event): wx.MessageBox('Save Information', 'Info', wx.OK | wx.ICON_INFORMATION) # Init images processing def onStart(self, event): message = self.frame.panel_initial.parameters.ValidateInputs() if message == "": imageList = self.frame.panel_initial.image.traverseTree(True) emptyItems = self.frame.panel_initial.image.verifyEmptySamples() if not self.frame.panel_initial.image.traverseTree(False): wx.MessageBox(u'No hay Imágenes para Procesar', 'Error', wx.OK | wx.ICON_ERROR) else: if emptyItems: message_empty = u'Las siguientes muestras no tienen imágenes \n' for empty in emptyItems: message_empty = message_empty + u"\u2022" + u' Tiempo = ' + str(empty) + u' min \n' wx.MessageBox(message_empty, u'Información', wx.OK | wx.ICON_INFORMATION) else: for imagePath in imageList: if isinstance(imagePath, int): pass else: self.processImage(imagePath) #wx.MessageBox('Start Information', 'Info', wx.OK | wx.ICON_INFORMATION) else: wx.MessageBox(message, u'Error en Parámetros Iniciales', wx.OK | wx.ICON_ERROR) def onStop(self, event): wx.MessageBox('Stop Information', 'Info', wx.OK | wx.ICON_INFORMATION) # Output Browser Function (Open Folder Dialog to set output folder) def onOutput(self, event): self.openFolderDialog = wx.DirDialog(self.frame,"Abrir", style = wx.DD_DEFAULT_STYLE| wx.DD_DIR_MUST_EXIST) if self.openFolderDialog.ShowModal() == wx.ID_OK: self.textOutput.SetValue(self.openFolderDialog.GetPath()) self.openFolderDialog.Destroy() # Add sample Time in TreeCtrl def onAddFolder(self, event): dialog_add = AddFolderDialog(None) dialog_add.Centre() if dialog_add.ShowModal() == wx.ID_OK: value = dialog_add.text_time.GetValue() # Get List of all First Level items in Tree imageList = self.frame.panel_initial.image.traverseTree(True) # If TreeCtrl of images is empty, then add a sample time to tree if not imageList: self.imageTree.AppendItem(self.imageTree.GetRootItem(), 'Tiempo = ' + str(value) + ' min') dialog_add.Destroy() # If TreeCtrl of images is not empty, then to verify if value exist else add sample time to tree else: sampleList = False for sample in imageList: if sample == value: sampleList = True break if not sampleList: self.imageTree.AppendItem(self.imageTree.GetRootItem(), 'Tiempo = ' + str(value) + ' min') dialog_add.Destroy() else: wx.MessageBox('El tiempo de la muestra ya existe', u'Información', wx.OK | wx.ICON_INFORMATION) # Add Image paths to TreeCtrl def onAddFile(self, event): # open File Dialog (PNG, TIFF) self.openFileDialog = wx.FileDialog(self.frame,"Abrir", wildcard = "TIFF files (*.tif)|*.tif|PNG files (*.png)|*.png", style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST|wx.FD_MULTIPLE) if self.openFileDialog.ShowModal() == wx.ID_OK: # Verify if the parent of selected Item is the root or a level 1 item imageList = self.frame.panel_initial.image.traverseTree(False) imagePaths = self.openFileDialog.GetPaths() duplicatePaths = [] newPaths = [] exist = False # Verify if paths exits in the TreeCtrl for path in imagePaths: for image in imageList: if image == path: duplicatePaths.append(path) exist = True if not exist: newPaths.append(path) # verify if Path are not duplicate, else show info message if not duplicatePaths: pass else: message = 'Los siguientes archivos ya existen:\n' for path in duplicatePaths: message = message + u"\u2022 " + path + '\n' wx.MessageBox(message, 'Archivos duplicados', wx.OK | wx.ICON_ERROR) # Add Not duplicate path to TreCtrl, first verify the parent Item item = self.imageTree.GetSelections() # If have multiple item selected show information message if len(item) == 1: if self.imageTree.GetRootItem() == self.imageTree.GetItemParent(item[0]): self.frame.panel_initial.image.addItem(item[0], newPaths) self.imageTree.Expand(item[0]) else: self.frame.panel_initial.image.addItem(self.imageTree.GetItemParent(item[0]), newPaths) self.imageTree.Expand(self.imageTree.GetItemParent(item[0])) else: wx.MessageBox(u'Seleccione un solo elemento', 'Agregar', wx.OK | wx.ICON_INFORMATION) self.openFileDialog.Destroy() # Remove Selected items of TreeCtrl def onRemove(self, event): items = self.imageTree.GetSelections() message = u'Desea eliminar los siguientes archivos: \n' for path in items: message = message + u"\u2022 " + self.imageTree.GetItemText(path) + "\n" dialog_remove = wx.MessageDialog(self.frame, message, 'Eliminar') if dialog_remove.ShowModal() == wx.ID_OK: for item in items: self.imageTree.Delete(item) # Verify if TreeCtrl is empty and disable add_file button if not self.frame.panel_initial.image.list_files.GetSelections(): self.frame.panel_initial.image.button_addFile.Disable() self.frame.panel_initial.image.button_remove.Disable() else: self.frame.panel_initial.image.button_addFile.Enable() self.frame.panel_initial.image.button_remove.Enable() self.frame.panel_initial.image.removeImage() # Show selected path on the image panel def onSelChanged(self, event): # If any item is selected disable add_file and remove buttons item = event.GetItem() if not self.frame.panel_initial.image.list_files.GetSelections(): self.frame.panel_initial.image.button_addFile.Disable() self.frame.panel_initial.image.button_remove.Disable() else: self.frame.panel_initial.image.button_addFile.Enable() self.frame.panel_initial.image.button_remove.Enable() # If selected item is a Parent Item don't performs anything if self.imageTree.GetRootItem() == self.imageTree.GetItemParent(item): pass else: self.frame.panel_initial.image.onView((event.GetEventObject().GetItemText(item))) def disableInitialPanel(self): self.frame.panel def processImage(self, path): self.image.loadImage(path) self.image.getBinaryImage() self.image.showImage()
if __name__ == '__main__': import locale import wx import globals as gbl from models.dataset import AllocatDataSet from views.main_window import MainWindow gbl.COLOR_SCHEME = gbl.SKINS[gbl.pick_scheme()] app = wx.App() locale.setlocale(locale.LC_ALL, 'en_US') gbl.dataset = AllocatDataSet(gbl.DB_PATH) main_window = MainWindow() main_window.Show() app.MainLoop()
# -*- coding: utf-8 -*- from PyQt4 import QtGui from views.main_window import MainWindow import sys if __name__ == '__main__': app = QtGui.QApplication(sys.argv) main_win = MainWindow() main_win.show() sys.exit(app.exec_())
gbl.widestPrjName = w w = dc.GetTextExtent(prj['nickname'])[0] if w > gbl.widestNickname: gbl.widestNickname = w gbl.empNames = {uil.set2compare(e['name']): e['id'] for e in gbl.empRex.values()} gbl.widestEmpName = uil.getWidestTextExtent(font, empNames.values()) if __name__ == '__main__': import wx from views.main_window import MainWindow app = wx.App() # Set the font for the widest text calculations font = wx.Font(9, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) dc = wx.ScreenDC() dc.SetFont(font) build_globals() frm = MainWindow() frm.Show() app.MainLoop()