def set_GUI(self): """ Initialize GUI components. """ # Create the logo logo = QLabel() logoPixmap = QPixmap(resource_path("logo.png")) logo.setPixmap(logoPixmap) # Create the information labels appname = QLabel("Chess Claim Tool") appname.setObjectName("appname") version = QLabel("Version 0.2.1") version.setObjectName("version") copyright = QLabel("Serntedakis Athanasios 2019 © All Rights Reserved") copyright.setObjectName("copyright") # Align All elements to the center. logo.setAlignment(Qt.AlignCenter) appname.setAlignment(Qt.AlignCenter) version.setAlignment(Qt.AlignCenter) copyright.setAlignment(Qt.AlignCenter) # Add all the above elements to layout. layout = QVBoxLayout() layout.addWidget(logo) layout.addWidget(appname) layout.addWidget(version) layout.addWidget(copyright) self.setLayout(layout)
def __init__(self, *args): super().__init__(*args) # Updates self._toggled = False self._log_reader = None # Load Parsers self._load_parsers() self._settings = SettingsWindow() # Tray Icon self._system_tray = QSystemTrayIcon() self._system_tray.setIcon(QIcon(resource_path('data/ui/icon.png'))) self._system_tray.setToolTip("nParse") # self._system_tray.setContextMenu(self._create_menu()) self._system_tray.activated.connect(self._menu) self._system_tray.show() # Turn On self._toggle() if self.new_version_available(): self._system_tray.showMessage( "nParse Update".format(ONLINE_VERSION), "New version available!\ncurrent: {}\nonline: {}".format( CURRENT_VERSION, ONLINE_VERSION ), msecs=3000 )
def set_GUI(self): """ Initialize GUI components. """ # Create the first Horizontal Source Box. self.sourceHBox = SourceHBox(self) self.sources.append(self.sourceHBox) self.sourcesCounter = self.sourcesCounter + 1 # Create the Apply & Ok Button Box. self.bottomBox = BottomBox(self) # Create the Add New Source Icon. addsourceButton = QPushButton("") addsourceButton.setIcon(QIcon(resource_path("add_icon.png"))) addsourceButton.setIconSize( QSize(self.iconsSize + 4, self.iconsSize + 4)) addsourceButton.setObjectName('AddSource') addsourceButton.clicked.connect(self.on_addsourceButton_clicked) # Add all the above elements to layout. self.layout = QVBoxLayout() self.layout.addWidget(self.sourceHBox) self.layout.addWidget(addsourceButton, 1, Qt.AlignRight) self.layout.addWidget(self.bottomBox) self.setLayout(self.layout) self.adjustSize()
def __init__(self, dialog): super().__init__() self.dialog = dialog # Create the Combo Box with 2 options. self.selectSource = QComboBox() self.selectSource.addItems(["Web(url)", "Local"]) self.selectSource.currentIndexChanged.connect(self.select_change) # Create the Line Edit for user input. self.sourceValue = QLineEdit() self.sourceValue.textChanged.connect(self.line_edit_change) self.sourceValue.setPlaceholderText("http://example.com/pgn/games.pgn") # Choose File Button in case of the Local File Option self.chooseButton = QPushButton("Choose File") self.chooseButton.clicked.connect(self.on_chooseButton_clicked) self.chooseButton.setHidden(True) # Create the Status Image self.statusImage = QLabel() self.ok_pixmap = QPixmap(resource_path("check_icon.png")) self.error_pixmap = QPixmap(resource_path("error_icon.png")) # Create the Delete Button deleteButton = QPushButton("") deleteButton.setIcon(QIcon(resource_path("delete_icon.png"))) deleteButton.setIconSize( QSize(self.dialog.iconsSize, self.dialog.iconsSize)) deleteButton.setObjectName('DeleteSource') deleteButton.clicked.connect( partial(self.dialog.slots.on_deleteButton_clicked, self)) # Add all the above elements to layout. layout = QHBoxLayout() layout.addWidget(self.selectSource) layout.addWidget(self.sourceValue) layout.addWidget(self.chooseButton) layout.addWidget(self.statusImage) layout.addWidget(deleteButton) self.setLayout(layout) self.adjustSize()
def notify(self,type,players,move): """ Send notification depending on the OS. Args: type: The type of the draw (3 Fold Repetition, 5 Fold Repetition, 50 Moves Rule, 75 Moves Rule). players: The names of the players. move: With which move the draw is valid. """ if (platform.system() == "Darwin"): self.mac_notification.clearNotifications() self.mac_notification.notify(type,players,move) elif(platform.system() == "Windows"): self.win_notification.show_toast(type, players+"\n"+move, icon_path=resource_path("logo.ico"), duration=5, threaded=True)
def __init__(self, *args): super().__init__(*args) # Plugin support self.plugins = PluginManager(self) self.plugins.discover_plugins(enable_all=config.data['general']['enable_plugins']) # End plugin support # Updates self._toggled = False self._log_reader = None # Load Parsers self._load_parsers() self._settings = SettingsWindow() # Tray Icon self._system_tray = QSystemTrayIcon() self._system_tray.setIcon(QIcon(resource_path('data/ui/icon.png'))) self._system_tray.setToolTip("nParse") # self._system_tray.setContextMenu(self._create_menu()) self._system_tray.activated.connect(self._menu) self._system_tray.show() # Turn On self._toggle() if self.new_version_available(): self._system_tray.showMessage( "nParse Update".format(ONLINE_VERSION), "New version available!\ncurrent: {}\nonline: {}".format( CURRENT_VERSION, ONLINE_VERSION ), msecs=3000 ) self.plugins.hook(Plugin.on_app_start, self)
def new_version_available(self): # this will only work if numbers go up try: for (o, c) in zip(ONLINE_VERSION.split('.'), CURRENT_VERSION.split('.')): if int(o) > int(c): return True except: return False if __name__ == "__main__": try: import ctypes APPID = 'nomns.nparse' ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(APPID) except: pass APP = NomnsParse(sys.argv) APP.setStyleSheet(open(resource_path('data/ui/_.css')).read()) APP.setWindowIcon(QIcon(resource_path('data/ui/icon.png'))) APP.setQuitOnLastWindowClosed(False) APP.setAttribute(Qt.AA_EnableHighDpiScaling) QFontDatabase.addApplicationFont( resource_path('data/fonts/NotoSans-Regular.ttf')) QFontDatabase.addApplicationFont( resource_path('data/fonts/NotoSans-Bold.ttf')) sys.exit(APP.exec())
def set_GUI(self): """ Initialize GUI components. """ # Create the Menu self.livePgnOption = QAction('Live PGN',self) self.livePgnOption.setCheckable(True) aboutAction = QAction('About',self) menubar = self.menuBar() optionsMenu = menubar.addMenu('&Options') optionsMenu.addAction(self.livePgnOption) aboutMenu = menubar.addMenu('&Help') aboutMenu.addAction(aboutAction) aboutAction.triggered.connect(self.slots.on_about_clicked) # Create the Claims Table (TreeView) self.claimsTable = QTreeView() self.claimsTable.setFocusPolicy(Qt.NoFocus) self.claimsTable.setEditTriggers(QAbstractItemView.NoEditTriggers) self.claimsTable.header().setDefaultAlignment(Qt.AlignCenter) self.claimsTable.setSortingEnabled(True) self.claimsTable.doubleClicked.connect(self.open_game) # Create the Claims Model self.claimsTableModel = QStandardItemModel() labels = ["#","Timestamp","Type","Board","Players","Move"] self.claimsTableModel.setHorizontalHeaderLabels(labels) self.claimsTable.setModel(self.claimsTableModel) # Create the Scan & Stop Button Box self.buttonBox = ButtonBox(self) # Create the Sources Button sourcesButton = QPushButton("Add Sources") sourcesButton.setObjectName("sources") sourcesButton.clicked.connect(self.slots.on_sourcesButton_clicked) # Create the Status Bar self.pixmapCheck = QPixmap(resource_path("check_icon.png")) self.pixmapError = QPixmap(resource_path("error_icon.png")) self.sourceLabel = QLabel() self.sourceLabel.setObjectName("source-label") self.sourceImage = QLabel() self.sourceImage.setObjectName("source-image") self.downloadLabel = QLabel() self.downloadLabel.setObjectName("download-label") self.downloadImage = QLabel() self.downloadImage.setObjectName("download-image") self.scanningLabel = QLabel() self.scanningLabel.setObjectName("scanning") self.spinnerLabel = QLabel() self.spinnerLabel.setVisible(False) self.spinnerLabel.setObjectName("spinner") self.spinner = QMovie(resource_path("spinner.gif")) self.spinner.setScaledSize(QSize(self.iconsSize, self.iconsSize)) self.spinnerLabel.setMovie(self.spinner) self.spinner.start() self.statusBar = QStatusBar() self.statusBar.setSizeGripEnabled(False) self.statusBar.addWidget(self.sourceLabel) self.statusBar.addWidget(self.sourceImage) self.statusBar.addWidget(self.downloadLabel) self.statusBar.addWidget(self.downloadImage) self.statusBar.addWidget(self.scanningLabel) self.statusBar.addWidget(self.spinnerLabel) self.statusBar.addPermanentWidget(sourcesButton) self.statusBar.setContentsMargins(10,5,9,5) # Container Layout for the Central Widget containerLayout = QVBoxLayout() containerLayout.setSpacing(0) containerLayout.addWidget(self.claimsTable) containerLayout.addWidget(self.buttonBox) # Central Widget containerWidget = QWidget() containerWidget.setLayout(containerLayout) self.setCentralWidget(containerWidget) self.setStatusBar(self.statusBar)
GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import sys, platform from ChessClaimController import ChessClaimController from ChessClaimView import ChessClaimView from PyQt5.QtWidgets import QApplication from PyQt5.QtCore import Qt from PyQt5.QtGui import QIcon from helpers import resource_path if __name__ == '__main__': QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True) app = ChessClaimController() app.setStyle('fusion') app.setWindowIcon(QIcon(resource_path("logo.png"))) """Load the CSS file for the application""" css = "main.css" with open(resource_path(css), 'r') as myfile: css = myfile.read().replace('\n', '') app.setStyleSheet(css) view = ChessClaimView() app.set_view(view) app.do_start() sys.exit(app.exec_())