def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) # MOVE WINDOW def moveWindow(event): # RESTORE BEFORE MOVE if UIFunctions.returnStatus() == 1: UIFunctions.maximize_restore(self) # IF LEFT CLICK MOVE WINDOW if event.buttons() == Qt.LeftButton: self.move(self.pos() + event.globalPos() - self.dragPos) self.dragPos = event.globalPos() event.accept() # SET TITLE BAR self.ui.title_bar.mouseMoveEvent = moveWindow ## ==> SET UI DEFINITIONS UIFunctions.uiDefinitions(self) ## SHOW ==> MAIN WINDOW ######################################################################## self.show()
def __init__(self): super(MainWindow, self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.selectAreaWidget = None self.rubberBand = QRubberBand(QRubberBand.Rectangle, self) self.screenshotWidget = None color = QColor(72, 41, 12).name(QColor.HexRgb) self.ui.hexColorLabel.setText(color) self.ui.bobberColorLabel.setStyleSheet("QLabel { background-color : " + color + "; }") self.fish = GetTheFish() self.fish.gui = True self.updateGui() self.thread = ThreadRunner(self.fish) # connects self.ui.colorButton.clicked.connect(self.openScreenshot) self.ui.startButton.clicked.connect(self.toggleFishing) self.ui.areaButton.clicked.connect(self.take_screenshot) self.ui.thresholdBobberSpinBox.valueChanged.connect(self.guiUpdated) self.ui.thresholdCatchSpinBox.valueChanged.connect(self.guiUpdated) self.ui.jumpToBobberCheck.stateChanged.connect(self.guiUpdated) self.ui.verboseCheck.stateChanged.connect(self.guiUpdated)
def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.setWindowFlag(QtCore.Qt.FramelessWindowHint) self.setAttribute(QtCore.Qt.WA_TranslucentBackground) self.ui.back2_btn2.clicked.connect(lambda: self.ui.stacked_wid.setCurrentIndex(0)) self.ui.create_btn.clicked.connect(lambda: self.ui.stacked_wid.setCurrentIndex(1)) self.ui.back_btn.clicked.connect(lambda: self.ui.stacked_wid.setCurrentIndex(0)) self.ui.add_btn.clicked.connect(lambda: self.ui.stacked_wid.setCurrentIndex(3)) self.ui.back_btn3.clicked.connect(lambda: self.ui.stacked_wid.setCurrentIndex(2)) self.ui.proceed_btn.clicked.connect(lambda: self.validation(self.ui.massterpw_entry.text())) self.ui.choosepath_btn.clicked.connect(self.create_db) self.ui.createdb_btn_2.clicked.connect(self.finalize_db) self.ui.choosefile_btn.clicked.connect(self.choose_db) self.ui.submit_btn.clicked.connect(self.add) self.ui.massterpw_entry.returnPressed.connect(lambda: self.validation(self.ui.massterpw_entry.text())) self.ui.confirmmasterpw2_entry.returnPressed.connect(self.finalize_db) self.ui.url_entry.returnPressed.connect(self.add) self.ui.close_lbl.mousePressEvent = lambda e: self.close() self.ui.min_lbl.mousePressEvent = lambda e: self.showMinimized() self.filepath = None
def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.mode = 'OFF' self.sound = 1 self.voice = 0 self.soundplayerbtn = soundplayingbuttons() self.soundplayerstatus = soundplayingstatus() self.mouse = movemouse() self.openingfile = openfile() self.labviewfilehandling = labviewmode() self.modecheckbtn = modecheckbutton() self.modecheckbtn.signal.connect(self.modechange) self.modecheckbtn.start() def moveWindow(event): if UIFunctions.returnStatus() == 1: UIFunctions.maximize_restore(self) if event.buttons() == Qt.LeftButton: self.move(self.pos() + event.globalPos() - self.dragPos) self.dragPos = event.globalPos() event.accept() self.ui.titl_frame.mouseMoveEvent = moveWindow UIFunctions.uiDefinitions(self) self.show()
def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) ## TOGGLE SUB MENUS ######################################################################## #self.ui.Btn_Toggle.clicked.connect(lambda: UIFunctions.toggleMenu(self, 200, True)) self.ui.Btn_hpc.clicked.connect(lambda: UIFunctions.openSubMenu( self, 240, self.ui.frame_hpc, True)) self.ui.Btn_spc.clicked.connect(lambda: UIFunctions.openSubMenu( self, 240, self.ui.frame_spc, True)) self.ui.Btn_dpc.clicked.connect(lambda: UIFunctions.openSubMenu( self, 240, self.ui.frame_dpc, True)) self.ui.Btn_ssc.clicked.connect(lambda: UIFunctions.openSubMenu( self, 240, self.ui.frame_ssc, True)) self.ui.Btn_alc.clicked.connect(lambda: UIFunctions.openSubMenu( self, 240, self.ui.frame_alc, True)) self.ui.Btn_cmt.clicked.connect(lambda: UIFunctions.openSubMenu( self, 240, self.ui.frame_cmt, True)) ## NAVIGATING PAGES self.ui.Btn_spc_main.clicked.connect( lambda: UIFunctions.handleButton(self, 1)) self.ui.Btn_hpc_main.clicked.connect( lambda: UIFunctions.handleButton(self, 0)) self.ui.Btn_hpc_mat.clicked.connect( lambda: UIFunctions.handleButton(self, 2)) ## SHOW ==> MAIN WINDOW ######################################################################## self.show()
def __init__(self, parent=None): self.main_win = QMainWindow() self.ui = Ui_MainWindow() self.ui.setupUi(self.main_win) self.ui.MakeMoneyButton.clicked.connect(self.on_MAKEMONEY_click) self.ui.lookupButton.clicked.connect(self.on_LOOKUP_click)
def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) # MOVE WINDOW def moveWindow(event): # RESTORE BEFORE MOVE if UIFunctions.returnStatus() == 1: UIFunctions.maximize_restore(self) # IF LEFT CLICK MOVE WINDOW if event.buttons() == Qt.LeftButton: self.move(self.pos() + event.globalPos() - self.dragPos) self.dragPos = event.globalPos() event.accept() # SET TITLE BAR self.ui.title_bar.mouseMoveEvent = moveWindow ## ==> SET UI DEFINITIONS UIFunctions.uiDefinitions(self) ## QTIMER ==> START self.timer = QtCore.QTimer() self.timer.timeout.connect(self.systemInformation) # TIMER IN MILLISECONDS self.timer.start(1000) ## SHOW ==> MAIN WINDOW ######################################################################## self.show()
def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.DF = pd.DataFrame([]) ## TOP ######################################################################## self.ui.BtnLoadDf.clicked.connect(lambda: DataFunc.get_data(self)) ## PAGES ######################################################################## # PAGE 1 self.ui_page1 = Ui_Page1(self) # PAGE 2 self.ui.Btn_Menu_2.clicked.connect( lambda: self.ui.Pages_Widget.setCurrentWidget(self.ui.page_2)) # PAGE 3 self.ui.Btn_Menu_3.clicked.connect( lambda: self.ui.Pages_Widget.setCurrentWidget(self.ui.page_3)) ## SHOW ==> MAIN WINDOW ######################################################################## self.show()
class AppWindow(QMainWindow): def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.setWindowFlag(QtCore.Qt.FramelessWindowHint) self.setAttribute(QtCore.Qt.WA_TranslucentBackground) def moveWindow(event): if UIFunctions.returnStatus(self) == 1: UIFunctions.maximize_restore(self) if event.buttons() == Qt.LeftButton: self.move(self.pos() + event.globalPos() - self.dragPos) self.dragPos = event.globalPos() event.accept() self.ui.frame_titleBar_title.mouseMoveEvent = moveWindow UIFunctions.uiDefinitions(self) # EVENT def mousePressEvent(self, event): self.dragPos = event.globalPos() def resizeEvent(self, event): return super(AppWindow, self).resizeEvent(event)
class MainWindow(QMainWindow): def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.setWindowTitle('Knowledge On The Go') self.ui.Btn_Toggle.clicked.connect(lambda: UIFunctions.toggle_menu(self, 250, True)) # PAGE 1 - Dictionary self.ui.btn_page_1.clicked.connect(lambda: self.ui.stackedWidget.setCurrentWidget(self.ui.page_1)) # PAGE 2 - Wikipedia self.ui.btn_page_2.clicked.connect(lambda: self.ui.stackedWidget.setCurrentWidget(self.ui.page_2)) # PAGE 3 - Message-Server self.ui.btn_page_3.clicked.connect(lambda: self.server()) # PAGE 4 - Message-Client self.ui.btn_page_4.clicked.connect(lambda: self.client()) def server(self): print() print() import server def client(self): print() print() import client
def __init__(self): super(MainWindow, self).__init__() self.main_win = QMainWindow() self.ui = Ui_MainWindow() self.main_win.setWindowFlag(Qt.FramelessWindowHint) self.ui.setupUi(self.main_win) self.ui.stackedWidget.setCurrentWidget(self.ui.home_page) self.ui.actionBanking_Sector.triggered.connect(self.show_banking_form) self.ui.actionDesigning_Sector_3.triggered.connect( self.show_designing_form) self.ui.actionChange_Password.triggered.connect(self.change_password) self.ui.actionBanking_Sector_2.triggered.connect(self.bank_view_page) self.ui.actionDesigning_Sector_4.triggered.connect( self.design_view_page) self.ui.actionExit_2.triggered.connect(self.closemainwindow) self.ui.actionAll_2.triggered.connect(self.statement_form) self.ui.back_search_btn.clicked.connect(self.backtohomepage) self.ui.back_search_btn_2.clicked.connect(self.backtohomepage) self.ui.actionBanking.triggered.connect(self.show_popup) self.ui.actionBanking_Sector_5.triggered.connect( self.show_banking_tform) self.ui.actionDesigning_Sector_7.triggered.connect( self.show_designing_tform) self.ui.actionLadger.triggered.connect(self.show_ledger) self.ui.actionTab_View.triggered.connect(self.show_tabs) timer = QTimer(self) timer.timeout.connect(self.showtime) timer.start(1000)
class BrowserWindow(QtGui.QWidget): """Das Hauptfenster des Browsers.""" def __init__(self, *args): QtGui.QMainWindow.__init__(self, *args) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.createConnects() def createConnects(self): self.ui.editAddress.returnPressed.connect(self.loadPage) self.ui.webView.urlChanged.connect(self.updateUrl) self.ui.buttonBack.clicked.connect(self.ui.webView.back) self.ui.buttonForward.clicked.connect(self.ui.webView.forward) self.ui.buttonReload.clicked.connect(self.ui.webView.reload) @QtCore.pyqtSlot(QtCore.QUrl) def updateUrl(self, url): self.ui.editAddress.setText(url.toString()) @QtCore.pyqtSlot() def loadPage(self): stringUrl = unicode(self.ui.editAddress.text()) if not re.search(r"^http", stringUrl): stringUrl = "http://" + stringUrl url = QtCore.QUrl(stringUrl) self.ui.webView.load(url) self.ui.editAddress.clearFocus()
class BrowserWindow(QtGui.QWidget): """Das Hauptfenster des Browsers.""" def __init__(self, *args): QtGui.QMainWindow.__init__(self, *args) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.createConnects() def createConnects(self): self.ui.editAddress.returnPressed.connect(self.loadPage) self.ui.webView.urlChanged.connect(self.updateUrl) self.ui.buttonBack.clicked.connect(self.ui.webView.back) self.ui.buttonForward.clicked.connect(self.ui.webView.forward) self.ui.buttonReload.clicked.connect(self.ui.webView.reload) @QtCore.pyqtSlot(QtCore.QUrl) def updateUrl(self, url): self.ui.editAddress.setText(url.toString()) @QtCore.pyqtSlot() def loadPage(self): stringUrl = unicode(self.ui.editAddress.text()) if not re.search(r"^http", stringUrl): stringUrl = "http://" +stringUrl url = QtCore.QUrl(stringUrl) self.ui.webView.load(url) self.ui.editAddress.clearFocus()
def __init__(self): self.videolist = [] # save the list of unwatched videos self.watched = [] # Save the list of watched videos self.emotion = 0 # store the numerical value of emotion self.saved = 0 # Flag to check video anotation is saved or not before pressing next self.image = None self.cap = None self.timer = None self.main_win = QMainWindow() self.ui = Ui_MainWindow() self.ui.setupUi(self.main_win) self.ui.currentfolder = None self.ui.currentvideo = None self.ui.folderpath.setText("No Folder Selected") self.ui.emotion.setText("None") self.ui.Videoname.setText("None") self.ui.folder.clicked.connect(self.selectfolder) self.ui.save.clicked.connect(self.saveclicked) self.ui.replay.clicked.connect(self.replayclicked) self.ui.next.clicked.connect(self.nextclicked) self.ui.angry.clicked.connect(self.angryclicked) self.ui.happy.clicked.connect(self.happyclicked) self.ui.sad.clicked.connect(self.sadclicked) self.ui.surprise.clicked.connect(self.surpriseclicked) self.ui.disgust.clicked.connect(self.disgustclicked) self.ui.fear.clicked.connect(self.fearclicked) self.ui.noemotion.clicked.connect(self.noemotionclicked) self.ui.uncertain.clicked.connect(self.uncertainclicked)
def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) ## TOGGLE/BURGUER MENU ######################################################################## self.ui.Btn_Toggle.clicked.connect( lambda: UIFunctions.toggleMenu(self, 250, True)) ## PAGES ######################################################################## # PAGE 1 self.ui.btn_page_1.clicked.connect( lambda: self.ui.stackedWidget.setCurrentWidget(self.ui.page_1)) # PAGE 2 self.ui.btn_page_2.clicked.connect( lambda: self.ui.stackedWidget.setCurrentWidget(self.ui.page_2)) # PAGE 3 self.ui.btn_page_3.clicked.connect( lambda: self.ui.stackedWidget.setCurrentWidget(self.ui.page_3)) ## SHOW ==> MAIN WINDOW ######################################################################## self.show()
class MainWindow: def __init__(self, parent=None): self.main_win = QMainWindow() self.ui = Ui_MainWindow() self.ui.setupUi(self.main_win) self.ui.MakeMoneyButton.clicked.connect(self.on_MAKEMONEY_click) self.ui.lookupButton.clicked.connect(self.on_LOOKUP_click) def show(self): self.main_win.show() def on_LOOKUP_click(self): userSymbol = self.ui.stockSymbol.text().upper() lookup_info = "Current price of " + userSymbol + ": " + str( get_current_stock_price(userSymbol)) self.ui.OutputText.setText(lookup_info) def on_MAKEMONEY_click(self): if self.ui.stockSymbol.hasAcceptableInput() == False: self.ui.OutputText.setText("Please enter a valid stock symbol") if self.ui.desiredMargins.text().isdigit() == False: self.ui.OutputText.setText("Please enter a number greater than 0") userSymbol = self.ui.stockSymbol.text().upper() userMargins = float(self.ui.desiredMargins.text()) / 100 self.ui.OutputText.setText(marginBot(userSymbol, userMargins))
def __init__(self): QMainWindow.__init__(self) # Set up the user interface from QtDesigner self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.act_periph = [] self.ui.menu_periph = [] self.ui.lab_status = QLabel() self.ui.lab_status.setText("No connection") self.ui.statusBar.addPermanentWidget(self.ui.lab_status) self.about_dialog = QDialog(self) self.about_dialog.ui = Ui_AboutDialog() self.about_dialog.ui.setupUi(self.about_dialog) self.svd_dialog = QDialog(self) self.svd_dialog.ui = Ui_SVDDialog() self.svd_dialog.ui.setupUi(self.svd_dialog) self.svd_dialog.ui.tree_svd.itemDoubleClicked.connect(self.handle_svd_dialog_item_double_clicked) self.svd_dialog.ui.tree_svd.headerItem().setText(0, "List of packed SVD") # Add some vars self.svd_reader = SVDReader() self.openocd_tn = OpenOCDTelnet() self.openocd_rt = None self.opt_autoread = False
def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) ## PAGES ######################################################################## # PAGE 1 self.ui.btn_page_1.clicked.connect( lambda: self.ui.stackedWidget.setCurrentWidget(self.ui.page_1)) # PAGE 2 self.ui.btn_page_2.clicked.connect( lambda: self.ui.stackedWidget.setCurrentWidget(self.ui.page_2)) # PAGE 3 self.ui.btn_page_3.clicked.connect( lambda: self.ui.stackedWidget.setCurrentWidget(self.ui.page_3)) ######################################################################## app.aboutToQuit.connect(lambda: UIFunctions.closeEvent(self)) self.ui.pushButton.clicked.connect( lambda: UIFunctions.clickedButton(self)) #self.ui.pushButton.clicked.connect(lambda: UIFunctions.clickedButton(self)) ## SHOW ==> MAIN WINDOW ######################################################################## self.show()
def __init__(self): super(MainWindow, self).__init__() self.logger = logging.getLogger('MainWindow') self.ui = Ui_MainWindow() self.rootDir = Path(__file__).parent self.dbDir = os.path.join(self.rootDir, "db") self.configFile = os.path.join(self.rootDir, 'src', 'config', 'config.yaml') self.config = self.load_yml() # UI Stuff self.ui.setupUi(self) self.ui_functions = ui_Functions(self, self.ui) self.ui_functions.setWindowTitle(self.config['app']['title']) self.setWindowIcon(QtGui.QIcon(os.path.join(self.rootDir, 'App.ico'))) # Connectors self.ui.btn_close.clicked.connect(self.window_close) self.ui.btn_max.clicked.connect(self.ui_functions.maximize_restore) self.ui.btn_min.clicked.connect(self.showMinimized) # Database Setup -------------------------- self.db = Database(self.dbDir) # Setup Tables ---------------------------- table_user = Users(self, "users") table_user.setup() QtCore.QTimer.singleShot(500, lambda: self.test())
def __init__(self, parent=None): QWidget.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.timer = QTimer() self.timer.setInterval(2) self.timer.timeout.connect(self.maim_task) self.timer.start()
def __init__(self): super(MyApp, self).__init__() QtWidgets.QMainWindow.__init__(self) Ui_MainWindow.__init__(self) # Configure l'interface utilisateur. self.setupUi(self) self.Liste_Employes.triggered.connect(self.toListe_emp) self.Competences.triggered.connect(self.toComp) self.Details_Operation.triggered.connect(self.toOp)
def __init__(self, lst): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.Boxes = [] self.newlist = [] self.today_news_list = lst self.Refresh() self.show()
def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) # MAIN WINDOW LABEL QtCore.QTimer.singleShot( 1500, lambda: self.ui.label.setText( "<strong>THANKS</strong> FOR WATCHING")) QtCore.QTimer.singleShot( 1500, lambda: self.setStyleSheet("background-color: #222; color: #FFF"))
class Main(QtGui.QMainWindow): """ Módulo principal del sistema """ def __init__(self): super(Main, self).__init__() self.ui = Ui_Main() self.ui.setupUi(self) # Cargamos las acciones al presionar el menú self.menu_actions() self.show() self.activar() def menu_actions(self): self.ui.actionModulo_Clientes.triggered.connect(self.load_mod1) self.ui.actionMarcas.triggered.connect(self.load_mod2) self.ui.actionModelosAutos.triggered.connect(self.load_mod3) self.ui.actionLogin.triggered.connect(self.load_mod4) def load_mod1(self): """carga modulo clientes""" widget = Mod1(self) self.setCentralWidget(widget) def load_mod2(self): """ carga modulo marcas """ widget = Mod2(self) self.setCentralWidget(widget) def load_mod3(self): """ carga modulo modelos """ widget = Mod3(self) self.setCentralWidget(widget) def load_mod4(self): """ carga modulo del login """ widget = Mod4(self) self.setCentralWidget(widget) def activar(self): """ Este metodo lo llamara el login para activar las opciones princupales [originalmente estan desasctivadas] """ self.ui.actionModulo_Clientes.setEnabled(True) self.ui.actionMarcas.setEnabled(True) self.ui.actionModelosAutos.setEnabled(True)
def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) #self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.WindowMinimizeButtonHint) self.setFixedSize(self.width(), self.height()) self.statusBar().setSizeGripEnabled(False) self.ui.lineEdit_email.setReadOnly(True) self.ui.lineEdit_name.setReadOnly(True) self.ui.lineEdit_password.setReadOnly(True) ## SHOW ==> MAIN WINDOW ######################################################################## self.show()
def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) ## TOGGLE/BURGUER MENU ######################################################################## self.ui.Btn_Toggle.clicked.connect(lambda: UIFunctions.toggleMenu(self, 250, True)) ## SHOW ==> MAIN WINDOW ######################################################################## self.show()
def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) ## DROP SHADOW EFFECT self.setAttribute(Qt.WA_TranslucentBackground) self.shadow = QGraphicsDropShadowEffect(self) self.shadow.setBlurRadius(20) self.shadow.setXOffset(0) self.shadow.setYOffset(0) self.shadow.setColor(QColor(0, 0, 0, 60)) self.ui.frame.setGraphicsEffect(self.shadow)
def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.Canvas_box.removeWidget(self.ui.Canvas_label) self.ui.Canvas_label = Canvas() self.ui.Canvas_label.initialize() # We need to enable mouse tracking to follow the mouse without the button pressed. # self.ui.Canvas_label.setMouseTracking(True) # Enable focus to capture key inputs. #self.ui.Canvas_label.setFocusPolicy(Qt.StrongFocus) self.ui.Canvas_box.addWidget(self.ui.Canvas_label) self.ui.stackedWidget.setCurrentWidget(self.ui.Drawing_page) # For the Drawing page self.ui.Drawing.clicked.connect(self.Drawing_page) # For the Home Page self.ui.Home.clicked.connect(self.Home_page) # For the Video self.ui.Video.clicked.connect(self.Camera_feed) #This is for the subition on the Canvas self.ui.sub.clicked.connect(self.sub_btn) # MOVE WINDOW def moveWindow(event): # RESTORE BEFORE MOVE if UIFunctions.returnStatus() == 1: UIFunctions.maximize_restore(self) # IF LEFT CLICK MOVE WINDOW if event.buttons() == Qt.RightButton: self.move(self.pos() + event.globalPos() - self.dragPos) self.dragPos = event.globalPos() event.accept() # SET TITLE BAR self.ui.title_bar.mouseMoveEvent = moveWindow ## ==> SET UI DEFINITIONS UIFunctions.uiDefinitions(self) ## SHOW ==> MAIN WINDOW ######################################################################## self.show()
class MainWindow(QMainWindow): def __init__(self, client): super(MainWindow, self).__init__() self.client = client # Set up the user interface from Designer. self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.info_group_box.setTitle("User: "******"%0.2f" % (balance / 100.0)) pattern = "Pay %0.2f to %s" if balance < 0 else "Receive %0.2f from %s" self.ui.transactions_list.clear() for user, value in transactions.items(): self.ui.transactions_list.addItem(pattern % (value / 100.0, user)) def pending(self): if not self._pending_dialog: self._pending_dialog = PendingWidget(self.client) self._pending_dialog.refresh() self._pending_dialog.show()
class MainWindow(QMainWindow): def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) # SET VALUE TO 0 self.ui.progressBar.setValue(0) # EXPAND BTN self.ui.btnExpand.clicked.connect(self.expand) # RETRACT BTN self.ui.btnRetract.clicked.connect(self.retract) # RESIZE MAIN WINDOW self.ui.btnResizeWindow.clicked.connect( lambda: self.resizeMainWindow(1200, 500)) # SHOW WINDOW self.show() # FUNCTION TO EXPAND PROGRESS BAR OR ANOTHER WIDGET def expand(self): # CREATE ANIMATION self.animation = QPropertyAnimation(self.ui.progressBar, b"value") self.animation.setDuration(2000) self.animation.setStartValue(0) self.animation.setEndValue(100) self.animation.setEasingCurve(QtCore.QEasingCurve.Linear) self.animation.start() def retract(self): # CREATE ANIMATION self.animation = QPropertyAnimation(self.ui.progressBar, b"value") self.animation.setDuration(2000) self.animation.setStartValue(100) self.animation.setEndValue(0) self.animation.setEasingCurve(QtCore.QEasingCurve.Linear) self.animation.start() def resizeMainWindow(self, width, height): # CREATE ANIMATION self.animation = QPropertyAnimation(self, b"size") self.animation.setDuration(1000) self.animation.setEndValue(QtCore.QSize(width, height)) self.animation.setEasingCurve(QtCore.QEasingCurve.InOutQuad) self.animation.start()
class MainWindow(QMainWindow): def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) # MAIN WINDOW LABEL QtCore.QTimer.singleShot( 3000, lambda: self.ui.label.setText( "<strong>Thank You</strong> for using Mudra")) QtCore.QTimer.singleShot( 1500, lambda: self.setStyleSheet("background-color: #222; color: #FFF")) window = tk.Tk() window.title("Mudra Camera Interface") window.iconphoto(False, tk.PhotoImage(file='mn.png')) window.geometry('500x500') window.configure(bg='#383A59') frame1 = tk.Frame(window) btn5 = tk.Button(frame1, text='Upload File', height=90, width=230, fg='black', compound='left') btn4_image = Image.open('./main.png') btn4_image = btn4_image.resize((50, 50), Image.ANTIALIAS) btn4_image = ImageTk.PhotoImage(btn4_image) # --------------- Button -------------------# btn_font = font.Font(size=25) btn4 = tk.Button(frame1, text='Launch', height=90, width=230, fg='black', command=record, image=btn4_image, compound='left') btn4['font'] = btn_font btn4.grid(row=5, pady=(20, 20), column=5) frame1.pack() window.mainloop()
def __init__(self, *args): super(Main, self).__init__(*args) self.ui = Ui_Main() self.ui.setupUi(self) icon = QtGui.QIcon("favicon.ico") self.setWindowIcon(icon) self.download_windows = File_Manager() self.date = datetime.fromisoformat('2011-11-04T00:00:00') self.state = True self.ui.time.setText(self.date.strftime('%H:%M:%S')) self.ui.dialog.clicked.connect(self.show_dialog) self.ui.video.clicked.connect(self.on_video) self.ui.file.clicked.connect(self.file_browser) self.ui.set_ip.clicked.connect(self.set_ip) self.ui.file_2.clicked.connect(self.show_files) self.record_state = QTimer() self.record_state.setInterval(1000) self.record_state.timeout.connect(self.onTimerOut) self.runing_state = QTimer() self.runing_state.setInterval(1000) self.stopEvent = threading.Event() self.stopEvent.clear()
def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.server_pointers = [] self.config_file = "config" self.server_list_layout = QtGui.QVBoxLayout() self.ui.server_list_container.setLayout(self.server_list_layout) self.ui.tab.content_set = "server_list" self.connect(self.ui.add_server_button, QtCore.SIGNAL('pressed()'),self.add_server_to_list) self.connect(self.ui.tabWidget, QtCore.SIGNAL("currentChanged(int)"),self.tab_changed) ### menu triggers ### wonder if i can connect this ways buttons, etc... ### lazy to read manual for it :P self.ui.actionExit.triggered.connect(QtGui.qApp.quit) ### :'-(((can not connect to a function)))-': #self.ui.actionOpen.triggered.connect(self.open_config_file()) self.connect(self.ui.actionOpen, QtCore.SIGNAL("triggered()"),self.open_config_file) self.get_servers_from_config()
def __init__(self): super(Main, self).__init__() self.ui = Ui_Main() self.ui.setupUi(self) # Cargamos las acciones al presionar el menú self.menu_actions() self.show() self.activar()
def __init__(self, parent=None): #http://pythonadventures.wordpress.com/2013/01/10/launch-just-one-instance-of-a-qt-application/ wid = self.get_pid() if_focus = os.popen('xdotool getactivewindow').readlines() #hide if the window have focues when executed again if if_focus[0] == wid: os.system('xdotool windowunmap "' + wid + '"') sys.exit() #Software already opened if wid: #Show os.system('xdotool windowmap ' + wid) #get focus os.system('xdotool windowactivate ' + wid) move_under_cursor() sys.exit() else: #Load the ui QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) #Set the MainWindow Title self.setWindowTitle(self.appname) #Connect the function with the signal self.ui.pushSettings.clicked.connect(self.openKeyDialog) self.ui.pushRefresh.clicked.connect(self.loadAsana) self.ui.pushAddTask.clicked.connect(self.addTask) self.ui.pushUpdate.clicked.connect(self.comboProjectChanged) self.ui.lineTask.returnPressed.connect(self.addTask) self.ui.comboWorkspace.currentIndexChanged.connect(self.comboWorkspaceChanged) self.ui.comboProject.currentIndexChanged.connect(self.comboProjectChanged) #When the software are closed on console the software are closed signal.signal(signal.SIGINT, signal.SIG_DFL) #Add hide parameter parser = argparse.ArgumentParser() parser.add_argument("--hide", help="hide the window at startup", action="store_true") args = parser.parse_args() #Show the form QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) self.show() if not args.hide: move_under_cursor() else: wid = self.get_pid() os.popen('xdotool windowunmap "' + wid + '"') self.loadAsana()
def __init__(self, parent=None): super(Window, self).__init__(parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.setupSignalsSlots() self.switchToMain() self.current_id = None self.led_model = LedModel() db = QSqlDatabase.addDatabase('QSQLITE') db.setDatabaseName('led-tool.db') db.open() self.manufacturers_model = QSqlTableModel() self.manufacturers_model.setTable("manufacturers") self.manufacturers_model.select() self.ui.brightness_group_table_view.setModel(self.led_model) self.ui.manufacturer_combo.setModel(self.manufacturers_model) self.ui.manufacturer_combo.setModelColumn(1) self.mapper = QDataWidgetMapper() self.mapper.setModel(self.led_model) self.mapper.addMapping(self.ui.name_edit, 1) self.mapper.addMapping(self.ui.typical_voltage_spin, 6) self.mapper.addMapping(self.ui.typical_current_spin, 7) self.mapper.addMapping(self.ui.thermal_resistance_spin, 4) self.mapper.addMapping(self.ui.reference_temperature_spin, 5) self.mapper.addMapping(self.ui.manufacturer_combo, 3) self.mapper.toFirst() self.ui.led_filter.installEventFilter(self) self.ui.main_stacked_widget.setCurrentIndex(1) self.ui.editor_stacked_widget.setCurrentIndex(0)
def __init__(self): QMainWindow.__init__(self) self.toggleHistory = False self.context = Ui_MainWindow() self.context.setupUi(self) # Define's a media player that play's music and connects the seeker bar to it's seek position. self.player = QMediaPlayer() self.player.positionChanged.connect(self.updateSeeker) # Connects callback functions to the buttons in the GUI. self.context.btnPlay.clicked.connect(self.playMusic) self.context.btnPause.clicked.connect(self.pauseMusic) self.context.btnStop.clicked.connect(self.stopMusic) self.context.btnShuffle.clicked.connect(self.shuffleMusic) self.context.btnHistory.clicked.connect(self.switchHistory) self.context.btnClearHistory.clicked.connect(self.clearHistory) self.context.btnFund.clicked.connect(self.fundAccount) self.context.btnRefreshStore.clicked.connect(self.refreshStore) self.context.btnBuy.clicked.connect(self.buyMusic) self.context.btnCheckout.clicked.connect(self.checkout) self.context.btnPurchaseHistory.clicked.connect(self.showPurchases) self.context.seekSlider.sliderMoved.connect(self.setPosition) self.context.btnProfile.clicked.connect(self.showProfile) self.context.btnManager.clicked.connect(self.showManagerPanel) self.context.btnLogout.clicked.connect(self.logout) # Connects the history list to the media player. self.historyCount = 0 self.context.btnClearHistory.setVisible(False) self.context.historyList.setVisible(False) self.context.historyList.setColumnWidth(0, 250) self.context.historyList.setColumnWidth(1, 60) self.context.historyList.setColumnWidth(2 , 150) self.context.historyList.verticalHeader().setVisible(False) self.context.historyList.cellDoubleClicked.connect(self.selectHistory) # Update's the GUI according to the current user's account info. self.updateAccountInfo()
class MainForm(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.server_pointers = [] self.config_file = "config" self.server_list_layout = QtGui.QVBoxLayout() self.ui.server_list_container.setLayout(self.server_list_layout) self.ui.tab.content_set = "server_list" self.connect(self.ui.add_server_button, QtCore.SIGNAL('pressed()'),self.add_server_to_list) self.connect(self.ui.tabWidget, QtCore.SIGNAL("currentChanged(int)"),self.tab_changed) ### menu triggers ### wonder if i can connect this ways buttons, etc... ### lazy to read manual for it :P self.ui.actionExit.triggered.connect(QtGui.qApp.quit) ### :'-(((can not connect to a function)))-': #self.ui.actionOpen.triggered.connect(self.open_config_file()) self.connect(self.ui.actionOpen, QtCore.SIGNAL("triggered()"),self.open_config_file) self.get_servers_from_config() def open_config_file(self): open_dialog = QtGui.QFileDialog() # open_dialog.exec_() # print open_dialog self.config_file = open_dialog.getOpenFileName() self.rebuild_config_gui(self.config_file) def rebuild_config_gui(self, config_file): print self.server_pointers for server in self.server_pointers: server.remove_server() print self.server_pointers self.get_servers_from_config(config_file) def add_server_to_list(self,name="",ip="",user="",passwd="",port="22"): server = ServerGUI_Node(self,name,ip,user,passwd,port) if self.server_pointers != None: self.server_pointers.append(server) else: self.server_pointers = [] self.server_pointers.append(server) self.server_list_layout.addWidget(server.group_box) # self.ui.server_list_layout.addWidget(group_box) def get_servers_from_config(self, config_file=None): server_list = server_connect.get_config(config_file) print server_list.server_list for server in server_list.server_list: self.add_server_to_list(server.name,server.ip, server.user,server.passwd,server.port) def set_edit_conf_menu_active(self): self.ui.menuConfiguration.setDisabled(False) def tab_changed(self, i): if self.ui.tabWidget.currentWidget().content_set == "conf": self.set_edit_conf_menu_active() elif self.ui.tabWidget.currentWidget().content_set == "server_list": self.ui.menuConfiguration.setDisabled(True)
class MainWindow(QMainWindow, Ui_MainWindow): #Create settings for the software settings = QSettings('Mte90', 'QAsana') settings.setFallbacksEnabled(False) version = '2.0' appname = 'QAsana - ' + version + ' by Mte90' workspaces_id = {} workspace_id = '' projects_id = {} project_id = '' proj_tasks_id = {} asana_api = None def __init__(self, parent=None): #http://pythonadventures.wordpress.com/2013/01/10/launch-just-one-instance-of-a-qt-application/ wid = self.get_pid() if_focus = os.popen('xdotool getactivewindow').readlines() #hide if the window have focues when executed again if if_focus[0] == wid: os.system('xdotool windowunmap "' + wid + '"') sys.exit() #Software already opened if wid: #Show os.system('xdotool windowmap ' + wid) #get focus os.system('xdotool windowactivate ' + wid) move_under_cursor() sys.exit() else: #Load the ui QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) #Set the MainWindow Title self.setWindowTitle(self.appname) #Connect the function with the signal self.ui.pushSettings.clicked.connect(self.openKeyDialog) self.ui.pushRefresh.clicked.connect(self.loadAsana) self.ui.pushAddTask.clicked.connect(self.addTask) self.ui.pushUpdate.clicked.connect(self.comboProjectChanged) self.ui.lineTask.returnPressed.connect(self.addTask) self.ui.comboWorkspace.currentIndexChanged.connect(self.comboWorkspaceChanged) self.ui.comboProject.currentIndexChanged.connect(self.comboProjectChanged) #When the software are closed on console the software are closed signal.signal(signal.SIGINT, signal.SIG_DFL) #Add hide parameter parser = argparse.ArgumentParser() parser.add_argument("--hide", help="hide the window at startup", action="store_true") args = parser.parse_args() #Show the form QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) self.show() if not args.hide: move_under_cursor() else: wid = self.get_pid() os.popen('xdotool windowunmap "' + wid + '"') self.loadAsana() def openKeyDialog(self): key, ok = QInputDialog.getText(self, 'Authorization Key', 'Insert the key:', QLineEdit.Normal, self.settings.value('Key')) if not self.settings.value('Key'): self.settings.setValue('Key', key) def loadAsana(self): if self.settings.value('Key') != -1: if self.settings.value('Key'): self.ui.comboWorkspace.currentIndexChanged.disconnect(self.comboWorkspaceChanged) QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) self.asana_api = asana.Client.access_token(self.settings.value('Key')) #get workspace workspace = self.asana_api.users.me() workspace = workspace['workspaces'] self.ui.comboWorkspace.clear() for workspace in self.asana_api.workspaces.find_all(): self.workspaces_id[workspace['name']] = workspace['id'] #populate the combobox self.ui.comboWorkspace.addItem(workspace['name']) self.ui.comboWorkspace.currentIndexChanged.connect(self.comboWorkspaceChanged) self.comboWorkspaceChanged() else: QMessageBox.critical(self.window(), "Key not configured", "Set the key for access to Asana!") else: QMessageBox.critical(self.window(), "Key not configured", "Set the key for access to Asana!") def comboWorkspaceChanged(self): self.ui.comboProject.currentIndexChanged.disconnect(self.comboProjectChanged) self.workspace_id = self.workspaces_id[self.ui.comboWorkspace.currentText()] #get projects self.ui.comboProject.clear() for projects in self.asana_api.projects.find_all({'workspace': self.workspace_id, 'archived': 'false'}): self.projects_id[projects['name']] = projects['id'] #populate the combobox self.ui.comboProject.addItem(projects['name']) self.ui.comboProject.currentIndexChanged.connect(self.comboProjectChanged) self.comboProjectChanged() def comboProjectChanged(self): if len(self.ui.comboProject.currentText()) > 0: self.project_id = self.projects_id[self.ui.comboProject.currentText()] #get project tasks qsubtasks = QStandardItemModel() for proj_tasks in self.asana_api.tasks.find_by_project(self.project_id, { 'completed_since': 'now'}): item = QStandardItem(proj_tasks['name']) item.setEditable(True) item.setToolTip('Double click to edit') if not proj_tasks['name'].endswith(':'): check = Qt.Unchecked item.setCheckState(check) item.setCheckable(True) self.projects_id[proj_tasks['name']] = proj_tasks['id'] item.setStatusTip(str(proj_tasks['id'])) else: font = QFont() font.setWeight(QFont.Bold) item.setFont(font) #populate the listview qsubtasks.appendRow(item) self.ui.listTasks.setModel(qsubtasks) QApplication.setOverrideCursor(QCursor(Qt.ArrowCursor)) qsubtasks.itemChanged.connect(self.checkTasks) def checkTasks(self, item): QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) if item.checkState(): self.asana_api.tasks.delete(self.projects_id[item.text()]) self.ui.listTasks.model().removeRow(item.row()) else: self.asana_api.tasks.update(item.statusTip(), {'id': item.statusTip(), 'name': item.text()}) QApplication.setOverrideCursor(QCursor(Qt.ArrowCursor)) def addTask(self): task = self.ui.lineTask.text() self.ui.lineTask.setText('') self.asana_api.tasks.create_in_workspace(self.workspace_id, {'name': task, 'projects': [self.project_id]}) self.comboProjectChanged() def get_pid(self): wid = os.popen('xdotool search --name "' + self.appname + '"').readlines() #Check if multiple rows output if len(wid) > 0: wid = wid[0] return wid
import sys import gevent import gevent.monkey gevent.monkey.patch_all() from PyQt5.QtWidgets import QApplication, QMainWindow from ui_main import Ui_MainWindow from PyQt5.Qt import Qt, QTimer, QFont import sys import telnetlib app = QApplication(sys.argv) window = QMainWindow() ui = Ui_MainWindow() def a(QKeyEvent): if QKeyEvent.key() == Qt.Key_Up: print 'up' if QKeyEvent.key() == Qt.Key_Down: print 'down' b(QKeyEvent) def send(): text = u"<span style='color:red'>{}</span>".format(ui.lineEdit.text()) ui.plainTextEdit.appendHtml(text) data = ui.lineEdit.text() t = u"{}\n".format(data).encode('cp1251')
class MainWindow(QtGui.QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.np_img = None self.image_actions = [] self._init_ui() self.view = self.ui.imageLabel self.image_opener = ImageOpener(self) self.image_saver = ImageSaver(self) self.image_editor = ImageEditor() self.image_history = History() self.user_settings_dump_n_loader = UserSettingsDumpNLoader() self.diff_images_dir = self.user_settings_dump_n_loader.get_diff_images_dir() self.golden_images_dir = self.user_settings_dump_n_loader.get_golden_images_dir() self._init_file_actions() self._init_M2_actions() self._init_M3_actions() self._init_M4_actions() self._init_M5_actions() self._init_M6_actions() self._enable_menu_items(False) def _init_ui(self): self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.imageLabel.setAlignment(QtCore.Qt.AlignCenter) self.setCentralWidget(self.ui.imageLabel) def _init_file_actions(self): self.ui.actionExit.triggered.connect(QtGui.qApp.quit) self.ui.actionOpen.triggered.connect(self._open_file) self.ui.actionSave.triggered.connect(self._save_file) self.ui.actionSave_As.triggered.connect(self.image_saver.save_as_file) self.ui.actionUndo.triggered.connect(self._undo) self.ui.actionRedo.triggered.connect(self._redo) self.image_actions.append(self.ui.actionSave) self.ui.actionSave_As.setEnabled(False) self._enable_undo_redo() def _init_M2_actions(self): self.ui.actionErosion.triggered.connect(lambda: self._image_editor_wrapper(self.image_editor.erosion)) self.ui.actionDilatation.triggered.connect(lambda: self._image_editor_wrapper(self.image_editor.dilatation)) self.ui.actionInversion.triggered.connect(lambda: self._image_editor_wrapper(self.image_editor.inversion)) self.image_actions.extend([self.ui.actionErosion, self.ui.actionDilatation, self.ui.actionInversion]) def _init_M3_actions(self): self.ui.actionIntegrating_filter.triggered.connect( lambda: self._image_editor_wrapper(self.image_editor.linear_filter, ImageEditor.integration_filter_matrix, ImageEditor.integration_filter_divisor) ) self.ui.actionBlur.triggered.connect(lambda: self._image_editor_wrapper(self.image_editor.linear_filter, ImageEditor.blur_matrix, ImageEditor.blur_divisor)) self.ui.actionSharpen.triggered.connect(lambda: self._image_editor_wrapper(self.image_editor.linear_filter, ImageEditor.sharpen_matrix, ImageEditor.sharpen_divisor)) self.ui.actionMake_new_custom_filter.triggered.connect(self._make_new_custom_filter) for filter_name, (matrix, divisor) in self.user_settings_dump_n_loader.get_filters().iteritems(): action = QtGui.QAction(self) action.setText(filter_name) action.triggered.connect(lambda: self._image_editor_wrapper(self.image_editor.linear_filter, matrix, divisor)) self.ui.menuCustom_filters.addAction(action) self.image_actions.extend([self.ui.actionIntegrating_filter, self.ui.actionBlur, self.ui.actionSharpen, self.ui.actionMake_new_custom_filter]) def _init_M4_actions(self): self.ui.actionWhite_noise.triggered.connect(lambda: self._get_two_params_and_edit("Probability (%)", "Range", self.image_editor.white_noise)) self.ui.actionDust.triggered.connect(lambda: self._get_two_params_and_edit("Probability (%)", "Min value", self.image_editor.dust)) self.ui.actionGrid.triggered.connect(lambda: self._get_two_params_and_edit("Width", "Height", self.image_editor.grid)) self.image_actions.extend([self.ui.actionWhite_noise, self.ui.actionDust, self.ui.actionGrid]) def _init_M5_actions(self): self.ui.actionDifference.triggered.connect(lambda: self._diff_images()) self.ui.actionSet_diff_images_path.triggered.connect(lambda: self._set_diff_images_dir(self._choose_directory())) self.ui.actionSet_golden_images_path.triggered.connect(lambda: self._set_golden_images_dir(self._choose_directory())) self.image_actions.extend([self.ui.actionDifference, self.ui.actionSet_diff_images_path, self.ui.actionSet_golden_images_path]) def _init_M6_actions(self): self.ui.actionMedian_filter_r_1.triggered.connect(lambda: self._image_editor_wrapper(self.image_editor.median_filter, 1)) self.ui.actionMedian_filter_r_2.triggered.connect(lambda: self._image_editor_wrapper(self.image_editor.median_filter, 2)) self.ui.actionMedian_filter_r_3.triggered.connect(lambda: self._image_editor_wrapper(self.image_editor.median_filter, 3)) self.image_actions.extend([self.ui.actionMedian_filter_r_1, self.ui.actionMedian_filter_r_2, self.ui.actionMedian_filter_r_3]) def _enable_menu_items(self, mode): for action in self.image_actions: action.setEnabled(mode) def _image_editor_wrapper(self, editor_func, *args): self.image_history.add_new_state(self.np_img) self.image_editor.update_image(self.np_img) self.np_img = editor_func(*args) self._show_np_image() self._enable_undo_redo() self._enable_menu_items(True) def _make_new_custom_filter(self): dialog = MakeNewCustomLinearFilterDialog(self.user_settings_dump_n_loader.get_filters().keys()) if dialog.exec_(): matrix, divisor, name = dialog.get_values() self._image_editor_wrapper(self.image_editor.linear_filter, matrix, divisor) self.user_settings_dump_n_loader.save_filter(matrix, divisor, name) action = QtGui.QAction(self) action.setText(name) self.ui.menuCustom_filters.addAction(action) action.triggered.connect(lambda: self._image_editor_wrapper(self.image_editor.linear_filter, matrix, divisor)) def _get_two_params_and_edit(self, param1, param2, editor_func): dialog = BaseTwoParamsDialog(param1, param2) if dialog.exec_(): param1_value, param2_value = dialog.get_values() self._image_editor_wrapper(editor_func, param1_value, param2_value) @staticmethod def _choose_directory(): return str(QtGui.QFileDialog.getExistingDirectory(None, 'Choose directory', '.', QtGui.QFileDialog.ShowDirsOnly)) def _set_golden_images_dir(self, dirname): if dirname: self.golden_images_dir = dirname self.user_settings_dump_n_loader.set_golden_images_dir(dirname) def _set_diff_images_dir(self, dirname): if dirname: self.golden_images_dir = dirname self.user_settings_dump_n_loader.set_diff_images_dir(dirname) def _diff_images(self): self.image_editor.update_image(self.np_img) basename = os.path.basename(str(self.image_saver.filename)) try: golden_np_img = scipy.misc.imread(os.path.join(str(self.golden_images_dir), basename)) is_ok, diff_img, percentage = self.image_editor.diff_images(golden_np_img) if not is_ok: QtGui.QMessageBox.about(self, 'Error', 'Images have different size.s') else: QtGui.QMessageBox.about(self, 'Diff percentage', 'diff: %.1f %%' % percentage) diff_filename = os.path.join(str(self.diff_images_dir), basename) if percentage: self.image_saver.save_any(diff_img, diff_filename) except IOError: QtGui.QMessageBox.about(self, 'Error', 'There is no golden image with corresponding name.') def _open_file(self): self.np_img = self.image_opener.open_file() self.image_history.reset() self.image_history.add_new_state(self.np_img) self.image_saver.filename = self.image_opener.filename # in case of png files swap channels if self.np_img.shape[2] == 4: self.np_img = utils.bgra2rgba(self.np_img) self._show_np_image() self._enable_menu_items(True) self._enable_undo_redo() self.ui.actionSave_As.setEnabled(True) def _save_file(self): self.image_saver.np_img = self.np_img self.image_saver.save_file() self.ui.actionSave.setEnabled(False) def _undo(self): if self.image_history.can_undo(): self.np_img = self.image_history.undo() self._show_np_image() self._enable_undo_redo() def _redo(self): if self.image_history.can_redo(): self.np_img = self.image_history.redo() self._show_np_image() self._enable_undo_redo() def _enable_undo_redo(self): undo_state, redo_state = True, True if not self.image_history.can_redo(): redo_state = False if not self.image_history.can_undo(): undo_state = False self.ui.actionRedo.setEnabled(redo_state) self.ui.actionUndo.setEnabled(undo_state) def _show_np_image(self): img = utils.np_to_qimage(self.np_img) self._show_image(img) def _show_image(self, img): pixmap = QtGui.QPixmap.fromImage(img) pixmap = self.scale_pixmap(pixmap) self.view.setPixmap(pixmap) def scale_pixmap(self, pixmap): dest_height, dest_width = self.view.size().height(), self.view.size().width() if dest_height < pixmap.size().height(): pixmap = pixmap.scaledToHeight(self.view.size().height()) elif dest_width < pixmap.size().width(): pixmap = pixmap.scaledToWidth(self.view.size().width()) return pixmap def show_window(self): self.show()
def _init_ui(self): self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.imageLabel.setAlignment(QtCore.Qt.AlignCenter) self.setCentralWidget(self.ui.imageLabel)
class Window(QMainWindow): def __init__(self, parent=None): super(Window, self).__init__(parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.setupSignalsSlots() self.switchToMain() self.current_id = None self.led_model = LedModel() db = QSqlDatabase.addDatabase('QSQLITE') db.setDatabaseName('led-tool.db') db.open() self.manufacturers_model = QSqlTableModel() self.manufacturers_model.setTable("manufacturers") self.manufacturers_model.select() self.ui.brightness_group_table_view.setModel(self.led_model) self.ui.manufacturer_combo.setModel(self.manufacturers_model) self.ui.manufacturer_combo.setModelColumn(1) self.mapper = QDataWidgetMapper() self.mapper.setModel(self.led_model) self.mapper.addMapping(self.ui.name_edit, 1) self.mapper.addMapping(self.ui.typical_voltage_spin, 6) self.mapper.addMapping(self.ui.typical_current_spin, 7) self.mapper.addMapping(self.ui.thermal_resistance_spin, 4) self.mapper.addMapping(self.ui.reference_temperature_spin, 5) self.mapper.addMapping(self.ui.manufacturer_combo, 3) self.mapper.toFirst() self.ui.led_filter.installEventFilter(self) self.ui.main_stacked_widget.setCurrentIndex(1) self.ui.editor_stacked_widget.setCurrentIndex(0) def setupSignalsSlots(self): self.ui.edit_led_button.clicked.connect(self.switchToEditor) self.ui.buttonBox.clicked.connect(self.switchToMain) def switchToEditor(self): self.ui.main_stacked_widget.setCurrentIndex(1) def switchToMain(self): self.ui.main_stacked_widget.setCurrentIndex(0) def eventFilter(self, source, event): if source is self.ui.led_filter: if event.type() == QEvent.KeyPress: if event.key() == Qt.Key_Escape: self.ui.led_filter.clear() return QWidget.eventFilter(self, source, event) def keyPressEvent(self, event): default = True if event.key() == Qt.Key_Escape: self.switchToMain() default = False # if (event.modifiers() & Qt.ControlModifier): # if event.key() == Qt.Key_C: #copy # self.copyTableToClipboard() # default = False # # if event.key() == Qt.Key_V: #paste # self.pasteClipboardToTable() # default = False if default: super(Window, self).keyPressEvent(event)
class MainWindow(QMainWindow): # Constructor which set's up the Main Window's GUI context. def __init__(self): QMainWindow.__init__(self) self.toggleHistory = False self.context = Ui_MainWindow() self.context.setupUi(self) # Define's a media player that play's music and connects the seeker bar to it's seek position. self.player = QMediaPlayer() self.player.positionChanged.connect(self.updateSeeker) # Connects callback functions to the buttons in the GUI. self.context.btnPlay.clicked.connect(self.playMusic) self.context.btnPause.clicked.connect(self.pauseMusic) self.context.btnStop.clicked.connect(self.stopMusic) self.context.btnShuffle.clicked.connect(self.shuffleMusic) self.context.btnHistory.clicked.connect(self.switchHistory) self.context.btnClearHistory.clicked.connect(self.clearHistory) self.context.btnFund.clicked.connect(self.fundAccount) self.context.btnRefreshStore.clicked.connect(self.refreshStore) self.context.btnBuy.clicked.connect(self.buyMusic) self.context.btnCheckout.clicked.connect(self.checkout) self.context.btnPurchaseHistory.clicked.connect(self.showPurchases) self.context.seekSlider.sliderMoved.connect(self.setPosition) self.context.btnProfile.clicked.connect(self.showProfile) self.context.btnManager.clicked.connect(self.showManagerPanel) self.context.btnLogout.clicked.connect(self.logout) # Connects the history list to the media player. self.historyCount = 0 self.context.btnClearHistory.setVisible(False) self.context.historyList.setVisible(False) self.context.historyList.setColumnWidth(0, 250) self.context.historyList.setColumnWidth(1, 60) self.context.historyList.setColumnWidth(2 , 150) self.context.historyList.verticalHeader().setVisible(False) self.context.historyList.cellDoubleClicked.connect(self.selectHistory) # Update's the GUI according to the current user's account info. self.updateAccountInfo() # Log's the user out of the system and saves the store's database. # Also pauses the music in order to prevent any interference when logging # into a different account from the previous login. def logout(self): global currentAccount currentAccount = Account() saveDatabase() loginForm.show() self.stopMusic() self.hide() # Updates and shows the manager panel if it is not already visible. def showManagerPanel(self): if (not managerPanel.isVisible()): managerPanel.updateSetList() managerPanel.exec_() # Updates and shows the profile dialog if it is not already visible. def showProfile(self): if (not profileDialog.isVisible()): profileDialog.updateDialog() profileDialog.exec_() # Updates and shows the purchase dialog if it is not already visible. def showPurchases(self): if (not purchaseHistory.isVisible()): purchaseHistory.updateHistory() purchaseHistory.exec_() # Updates and shows the checkout dialog if it is not already visible. def checkout(self): if (not checkoutForm.isVisible()): checkoutForm.updateCheckout() checkoutForm.exec_() # Returns the present song selected within the store's list. Return's null if no selection is made. def getCurrentSong(self): selectSong = None for index, song in songs.enum(): if (song.title == self.context.storeList.item(self.context.storeList.currentRow(), 0).text()): selectSong = song return selectSong # Add's a track to the user's cart according to their selection. def buyMusic(self): currentSong = self.getCurrentSong() # Determines if the user already has the track in their cart or purchases. if (not currentAccount.hasTrack(currentSong)): # Determines if there are more than 10 tracks in their cart. if (len(currentAccount.orders) == 9): QMessageBox.information(self, "Buy Track", "You can only purchase 10 tracks at a time.") else: # Display a confirmation message stating whether or not the user wants to buy the song. reply = QMessageBox.question(self, "Buy Track", "Are you sure you would like to add\n%s\nto your cart for $%s?" % (currentSong.title, str(currentSong.cost)), QMessageBox.Yes, QMessageBox.No) if (reply == QMessageBox.Yes): currentAccount.orders.append(currentSong) checkoutForm.updateCheckout() else: QMessageBox.information(self, "Buy Track", "This track is already in your cart, or you have already bought the track.") # Re-populates the store's inventory list. def refreshStore(self): loadMusic(False) # Funds the user's balance with an inputted amount of money. def fundAccount(self): try: currentAccount.fund(float(QInputDialog.getText(self, "Fund Account", "Amount:", QLineEdit.Normal, "0")[0])) QMessageBox.information(self, "Fund Account", "Your account has been successfully funded.") except ValueError: QMessageBox.information(self, "Fund Account", "The amount you wished to fund is invalid.") # Clear's the history list. def clearHistory(self): self.context.historyList.clearContents() self.context.historyList.setRowCount(0) self.historyCount = 0 # Toggles between the history list and store inventory list. def switchHistory(self): self.toggleHistory = not self.toggleHistory self.context.historyList.setVisible(self.toggleHistory) self.context.btnClearHistory.setVisible(self.toggleHistory) self.context.storeList.setVisible(not self.toggleHistory) self.context.btnRefreshStore.setVisible(not self.toggleHistory) if (self.toggleHistory): self.context.btnHistory.setText("Browse Store") else: self.context.btnHistory.setText("Play History") # Updates the GUI according to the current user's info. def updateAccountInfo(self): global currentAccount self.context.cashLabel.setText("$%.2f" % (currentAccount.balance)) # Set's the Manager Panel button visible if the user is a manager. self.context.btnManager.setVisible(currentAccount.status == MANAGER_ACCOUNT) # Re-populates the store inventory list. def fillMusicList(self): # Nullifies the present content in the store's inventory list. self.context.storeList.clearContents() # Re-populates the store list. self.context.storeList.setRowCount(songs.size()) self.context.storeList.setSortingEnabled(False) for index, song in songs.enum(): titleObj = QTableWidgetItem(song.title) durationObj = QTableWidgetItem(msToHms(int(song.duration))) artistObj = QTableWidgetItem(song.artist) priceObj = QTableWidgetItem(str(song.cost)) # Set's each widget on the store list as read-only. titleObj.setFlags(Qt.ItemIsEnabled) durationObj.setFlags(Qt.ItemIsEnabled) artistObj.setFlags(Qt.ItemIsEnabled) priceObj.setFlags(Qt.ItemIsEnabled) self.context.storeList.setItem(index, 0, titleObj) self.context.storeList.setItem(index, 1, durationObj) self.context.storeList.setItem(index, 2, artistObj) self.context.storeList.setItem(index, 3, priceObj) # Defines the store column widths. self.context.storeList.setColumnWidth(0, 250) self.context.storeList.setColumnWidth(1, 60) self.context.storeList.setColumnWidth(2 , 150) self.context.storeList.setSortingEnabled(True) self.context.storeList.verticalHeader().setVisible(False) self.context.storeList.cellDoubleClicked.connect(self.selectSong) # Shows the user how many track's are in stock. self.context.trackCount.setText("There are currently %s tracks in stock." % (str(songs.size()))) # A callback function that handles whenever a song is double clicked within the store inventory list. def selectSong(self, row, column): selectSong = self.getCurrentSong() if (selectSong != None): # Determine if a selection is present. self.context.seekSlider.setMaximum(int(selectSong.duration)) self.context.songName.setText(selectSong.title) # Play's the song. self.setMusic(selectSong.streamUrl, True) # Shows the user the song's thumbnail if the song has a thumbnail. Otherwise shows a blank canvas. if (selectSong.imageUrl != None): try: image = QPixmap() image.loadFromData(urllib.request.urlopen(selectSong.imageUrl).read()) image = image.scaled(QSize(225, 225), Qt.KeepAspectRatio, Qt.SmoothTransformation); scene = QGraphicsScene(self.context.songImage) scene.addPixmap(image) self.context.songImage.setScene(scene) except ValueError: image = QPixmap() scene = QGraphicsScene(self.context.songImage) scene.addPixmap(image) self.context.songImage.setScene(scene) # Add's the song to the history. self.addHistory(selectSong) # Add's an entry to the history list. def addHistory(self, song): tObj = QTableWidgetItem(song.title) dObj = QTableWidgetItem(msToHms(int(song.duration))) aObj = QTableWidgetItem(song.artist) pObj = QTableWidgetItem(str(song.cost)) # Set the widget for the history column to be read-only. tObj.setFlags(Qt.ItemIsEnabled) dObj.setFlags(Qt.ItemIsEnabled) aObj.setFlags(Qt.ItemIsEnabled) pObj.setFlags(Qt.ItemIsEnabled) self.context.historyList.setRowCount(self.historyCount + 1) self.context.historyList.setItem(self.historyCount, 0, tObj) self.context.historyList.setItem(self.historyCount, 1, dObj) self.context.historyList.setItem(self.historyCount, 2, aObj) self.context.historyList.setItem(self.historyCount, 3, pObj) self.historyCount += 1 # A callback function that handles whenever a song is double clicked within the history list. def selectHistory(self, row, column): selectSong = self.getCurrentSong() if (selectSong != None): # Determines if a selection is present. self.context.seekSlider.setMaximum(int(selectSong.duration)) self.context.songName.setText(selectSong.title) # Play's the song. self.setMusic(selectSong.streamUrl, True) # Shows the user the song's thumbnail if the song has a thumbnail. Otherwise shows a blank canvas. if (selectSong.imageUrl != None): try: image = QPixmap() image.loadFromData(urllib.request.urlopen(selectSong.imageUrl).read()) image = image.scaled(QSize(225, 225), Qt.KeepAspectRatio, Qt.SmoothTransformation); scene = QGraphicsScene(self.context.songImage) scene.addPixmap(image) self.context.songImage.setScene(scene) except ValueError: image = QPixmap() scene = QGraphicsScene(self.context.songImage) scene.addPixmap(image) self.context.songImage.setScene(scene) # Play's or sets a song on the media player according to a given stream URL. def setMusic(self, streamUrl, play=False): global soundcloud_api_key self.player.setMedia(QMediaContent(QUrl(streamUrl + "?client_id=" + soundcloud_api_key))) if (play): self.playMusic() # A callback function that binds the media player's seek position to the seek slider's position. def setPosition(self): self.player.setPosition(self.context.seekSlider.sliderPosition()) # Update's the seek slider's position as the media player streams a song. # Also update's the audio position label to the media player. def updateSeeker(self, position): self.context.seekSlider.setSliderPosition(position) self.context.audioPosition.setText(msToHms(position)) # Randomly play's a song in the store's inventory list. def shuffleMusic(self): randomRow = random.randint(0, self.context.storeList.rowCount()) self.context.storeList.setCurrentCell(randomRow, 0) self.selectSong(randomRow, 0) # Tell's the media player to play. def playMusic(self): self.player.play() # Tell's the media player to pause itself. def pauseMusic(self): self.player.pause() # Tell's the media player to pause itself and seek the current media towards it's # initial point. def stopMusic(self): self.player.stop()
def __init__(self, *args): QtGui.QMainWindow.__init__(self, *args) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.createConnects()