def init_ui(self): self.name_of_application = "upload.farm giffer" self.setWindowTitle(self.name_of_application) self.setWindowIcon(QtGui.QIcon( resource_path("icons/windows_icon.ico"))) self._create_layouts_and_widgets() self.show()
def init_ui(self): self.name_of_application = "upload.farm uploader v{}".format( __version__) self.add_email_to_application_name() self.setWindowTitle(self.name_of_application) self.setWindowIcon(QtGui.QIcon( resource_path("icons/windows_icon.ico"))) self._create_layouts_and_widgets()
def _create_layouts_and_widgets(self): self._table_layout = QGridLayout() self._table = QTableWidget(0, 6, self) self._table_header = QHeaderView(QtCore.Qt.Horizontal) self._table_header.setSectionResizeMode(QHeaderView.ResizeToContents) # self._table_header.stretchLastSection() self._table.setHorizontalHeader(self._table_header) self._table.setHorizontalHeaderLabels([ "Farmer", "Farm name", "Latest date", "Num\nuploads", "Latest\nURL", "GIF" ]) self._table.itemClicked.connect(self.item_clicked_handler) self._logo = QLabel() self._logo.setPixmap(QtGui.QPixmap(resource_path(LOGO_ICON))) self._annotated = QCheckBox("D&isplay farm info on gif") self._annotated.setChecked(True) self._frametime = QDoubleSpinBox() self._frametime.setSuffix(" sec/frame") self._frametime.setRange(0, 10) self._frametime.setSpecialValueText("default framerate") self._frametime.setValue(0) self._frametime.setAccelerated(True) self._frametime.setSingleStep(0.1) # if gifsicle_executable == None: # self._gifsicle_button = QPushButton("Your GIFs\naren't optimized!") # self._gifsicle_button.clicked.connect(self.gifpopup) self._exit_button = QPushButton("C&lose") self._exit_button.clicked.connect(self.close) self._table_layout.addWidget(self._table) self._vbox = QVBoxLayout() self._hbox_title = QHBoxLayout() self._vbox_title = QVBoxLayout() self._menubar = QHBoxLayout() self._hbox_title.addWidget(self._logo) self._hbox_title.addStretch(1) self._hbox_title.addLayout(self._vbox_title) self._vbox_title.addLayout(self._menubar) self._vbox_title.setAlignment(QtCore.Qt.AlignTop) # if gifsicle_executable == None: # self._menubar.addWidget(self._gifsicle_button) self._menubar.addWidget(self._annotated) self._menubar.addWidget(self._frametime) self._menubar.addStretch(1) self._menubar.addWidget(self._exit_button) self._vbox.addLayout(self._hbox_title) self._vbox.addLayout(self._table_layout) self._main_widget = QWidget() self._main_widget.setLayout(self._vbox) self._main_widget.setMinimumWidth(600) self._main_widget.setMinimumHeight(400) self.setCentralWidget(self._main_widget)
def _showhide(self): if not self.isVisible(): restore_mac_dock_icon() if sys.platform == 'darwin': qApp.setWindowIcon(QtGui.QIcon(resource_path('icons/windows_icon.ico'))) self.activate_main_window() else: remove_mac_dock_icon() self.hide()
def _showhide(self): if not self.isVisible(): restore_mac_dock_icon() if sys.platform == "darwin": qApp.setWindowIcon( QtGui.QIcon(resource_path("icons/windows_icon.ico"))) self.activate_main_window() else: remove_mac_dock_icon() self.hide()
def _create_layouts_and_widgets(self): self._table_layout = QGridLayout() self._table = QTableWidget(0,6,self) self._table_header = QHeaderView(QtCore.Qt.Horizontal) self._table_header.setSectionResizeMode(QHeaderView.ResizeToContents) # self._table_header.stretchLastSection() self._table.setHorizontalHeader(self._table_header) self._table.setHorizontalHeaderLabels(['Farmer','Farm name','Latest date','Num\nuploads','Latest\nURL','GIF']) self._table.itemClicked.connect(self.item_clicked_handler) self._logo = QLabel() self._logo.setPixmap(QtGui.QPixmap(resource_path(LOGO_ICON))) self._annotated = QCheckBox("D&isplay farm info on gif") self._annotated.setChecked(True) self._frametime = QDoubleSpinBox() self._frametime.setSuffix(' sec/frame') self._frametime.setRange(0,10) self._frametime.setSpecialValueText('default framerate') self._frametime.setValue(0) self._frametime.setAccelerated(True) self._frametime.setSingleStep(0.1) # if gifsicle_executable == None: # self._gifsicle_button = QPushButton("Your GIFs\naren't optimized!") # self._gifsicle_button.clicked.connect(self.gifpopup) self._exit_button = QPushButton("C&lose") self._exit_button.clicked.connect(self.close) self._table_layout.addWidget(self._table) self._vbox = QVBoxLayout() self._hbox_title = QHBoxLayout() self._vbox_title = QVBoxLayout() self._menubar = QHBoxLayout() self._hbox_title.addWidget(self._logo) self._hbox_title.addStretch(1) self._hbox_title.addLayout(self._vbox_title) self._vbox_title.addLayout(self._menubar) self._vbox_title.setAlignment(QtCore.Qt.AlignTop) # if gifsicle_executable == None: # self._menubar.addWidget(self._gifsicle_button) self._menubar.addWidget(self._annotated) self._menubar.addWidget(self._frametime) self._menubar.addStretch(1) self._menubar.addWidget(self._exit_button) self._vbox.addLayout(self._hbox_title) self._vbox.addLayout(self._table_layout) self._main_widget = QWidget() self._main_widget.setLayout(self._vbox) self._main_widget.setMinimumWidth(600) self._main_widget.setMinimumHeight(400) self.setCentralWidget(self._main_widget)
def launch(): freeze_support() check_app_running() me = singleton.SingleInstance() if sys.platform == 'win32': windows_appusermodelid() app = QApplication(sys.argv) app.setWindowIcon(QtGui.QIcon(resource_path('icons/windows_icon.ico'))) QApplication.setQuitOnLastWindowClosed(False) if check_settings() == False or is_user_info_invalid() == True: waiting = WaitingWindow() else: main = MainWindow() sys.exit(app.exec_())
def launch(): freeze_support() check_app_running() me = singleton.SingleInstance() if sys.platform == "win32": windows_appusermodelid() app = QApplication(sys.argv) app.setWindowIcon(QtGui.QIcon(resource_path("icons/windows_icon.ico"))) QApplication.setQuitOnLastWindowClosed(False) if check_settings() == False or is_user_info_invalid() == True: waiting = WaitingWindow() else: main = MainWindow() sys.exit(app.exec_())
def _create_layouts_and_widgets(self): self._logo = QLabel() self._logo.setPixmap(QtGui.QPixmap(resource_path(LOGO_ICON))) self._explanation = QTextEdit( "This tool is a thank-you to supporters of " "upload.farm.<br><br>It allows you to automatically backup your Stardew Valley " "savegames and upload them to upload.farm for safekeeping.<br><br>To begin using " "the uploader, please authenticate with your upload.farm account by pressing " "the button below, or by navigating to:<br><br>{}".format( AUTHENTICATION_URL)) self._explanation.setReadOnly(True) self._profile_button = QPushButton("&Authenticate") self._profile_button.clicked.connect(self.open_api_auth) self._help_button = QPushButton("&Help!") self._help_button.clicked.connect(self.open_help) self._vbox = QVBoxLayout() self._vbox.addStretch(1) logobox = QHBoxLayout() logobox.addStretch(1) logobox.addWidget(self._logo) logobox.addStretch(1) self._vbox.addLayout(logobox) self._vbox.addStretch(1) logobox = QHBoxLayout() logobox.addStretch(1) logobox.addWidget(self._explanation) logobox.addStretch(1) self._vbox.addLayout(logobox) self._vbox.addStretch(1) logobox = QHBoxLayout() logobox.addStretch(1) logobox.addWidget(self._profile_button) logobox.addWidget(self._help_button) logobox.addStretch(1) self._vbox.addLayout(logobox) self._vbox.addStretch(1) self._main_widget = QWidget() self._main_widget.setLayout(self._vbox) self._main_widget.setMinimumWidth(500) self._main_widget.setMinimumHeight(400) self.setCentralWidget(self._main_widget)
def _create_layouts_and_widgets(self): self._logo = QLabel() self._logo.setPixmap(QtGui.QPixmap(resource_path(LOGO_ICON))) self._explanation = QTextEdit("This tool is a thank-you to supporters of " "upload.farm.<br><br>It allows you to automatically backup your Stardew Valley " "savegames and upload them to upload.farm for safekeeping.<br><br>To begin using " "the uploader, please authenticate with your upload.farm account by pressing " "the button below, or by navigating to:<br><br>{}".format(AUTHENTICATION_URL)) self._explanation.setReadOnly(True) self._profile_button = QPushButton("&Authenticate") self._profile_button.clicked.connect(self.open_api_auth) self._help_button = QPushButton("&Help!") self._help_button.clicked.connect(self.open_help) self._vbox = QVBoxLayout() self._vbox.addStretch(1) logobox = QHBoxLayout() logobox.addStretch(1) logobox.addWidget(self._logo) logobox.addStretch(1) self._vbox.addLayout(logobox) self._vbox.addStretch(1) logobox = QHBoxLayout() logobox.addStretch(1) logobox.addWidget(self._explanation) logobox.addStretch(1) self._vbox.addLayout(logobox) self._vbox.addStretch(1) logobox = QHBoxLayout() logobox.addStretch(1) logobox.addWidget(self._profile_button) logobox.addWidget(self._help_button) logobox.addStretch(1) self._vbox.addLayout(logobox) self._vbox.addStretch(1) self._main_widget = QWidget() self._main_widget.setLayout(self._vbox) self._main_widget.setMinimumWidth(500) self._main_widget.setMinimumHeight(400) self.setCentralWidget(self._main_widget)
def init_tray(self): self._popup_shown = False self.trayIcon = QSystemTrayIcon(QtGui.QIcon(resource_path("icons/windows_icon.ico")),self) self.trayIconMenu = QMenu() self.openAction = QAction("&Show/Hide", self, triggered=self._showhide) self.startupAction = QAction("Start &Automatically", self, triggered=self.toggle_startup) self.exitAction = QAction("&Exit", self, triggered=self._icon_exit) self.startupAction.setCheckable(True) self.startupAction.setChecked(check_startup()) self.trayIconMenu.addAction(self.openAction) self.trayIconMenu.addSeparator() self.trayIconMenu.addAction(self.startupAction) self.trayIconMenu.addSeparator() self.trayIconMenu.addAction(self.exitAction) self.trayIcon.setContextMenu(self.trayIconMenu) self.trayIcon.activated.connect(self._icon_activated) self._show_when_systray_available()
def init_tray(self): self._popup_shown = False self.trayIcon = QSystemTrayIcon( QtGui.QIcon(resource_path("icons/windows_icon.ico")), self) self.trayIconMenu = QMenu() self.openAction = QAction("&Show/Hide", self, triggered=self._showhide) self.startupAction = QAction("Start &Automatically", self, triggered=self.toggle_startup) self.exitAction = QAction("&Exit", self, triggered=self._icon_exit) self.startupAction.setCheckable(True) self.startupAction.setChecked(check_startup()) self.trayIconMenu.addAction(self.openAction) self.trayIconMenu.addSeparator() self.trayIconMenu.addAction(self.startupAction) self.trayIconMenu.addSeparator() self.trayIconMenu.addAction(self.exitAction) self.trayIcon.setContextMenu(self.trayIconMenu) self.trayIcon.activated.connect(self._icon_activated) self._show_when_systray_available()
from urllib.parse import urljoin import subprocess import sys from math import log import requests # import imageio from PIL import Image, ImageFont, ImageDraw from PyQt5 import QtCore from ufapi import get_series_info from config import root_directory, server_location, gifsicle_executable from pyinstallerresourcesupport import resource_path FONT_PATH = resource_path("fonts/VT323.ttf") FINAL_PANEL_MULTIPLIER = 4 class AnimationThread(QtCore.QRunnable): def __init__(self, name, url, signal=None, **kwargs): super().__init__() self.name = name self.url = url self.signal = signal self.kwargs = kwargs self.button = kwargs.get("button") def run(self): filename = make_animation(self.name, self.url, **self.kwargs) if self.signal:
def set_bg_image(self): self.bgimage = QtGui.QImage(resource_path("images/bg.png")).scaled( self.size(), transformMode=QtCore.Qt.SmoothTransformation) palette = QtGui.QPalette() palette.setBrush(QtGui.QPalette.Window, QtGui.QBrush(self.bgimage)) self.setPalette(palette)
from watcherlib import Watcher, manual_process from config import server_location, client_id, backup_directory, gifsicle_executable from ufapi import get_user_email, get_user_uploads from uploadmonitor import launch_uploadmonitor_as_thread from multiprocessing import freeze_support from addtostartup import add_to_startup, remove_from_startup, check_startup from setup import version from versioninfo import version_is_current from pyinstallerresourcesupport import resource_path from animator import AnimationThread AUTHENTICATION_URL = server_location+"/auth?client_id="+client_id ACCOUNT_URL = server_location+"/acc" BACKUP_DIRECTORY = backup_directory RUN_STARDEW_VALLEY_STEAM = 'steam://rungameid/413150' HELP_FILE_LOCATION = "file:///{}".format(os.path.abspath(resource_path("help/help.html"))) LOGO_ICON = "images/logo.png" __version__ = version # QWebEngineView = QtWebEngineWidgets.QWebEngineView QWidget = QtWidgets.QWidget QMainWindow = QtWidgets.QMainWindow Signal = QtCore.pyqtSignal QApplication = QtWidgets.QApplication QLabel = QtWidgets.QLabel QHBoxLayout = QtWidgets.QHBoxLayout QVBoxLayout = QtWidgets.QVBoxLayout QTextEdit = QtWidgets.QTextEdit QCheckBox = QtWidgets.QCheckBox QDoubleSpinBox = QtWidgets.QDoubleSpinBox
import os import sys import subprocess import secrets from pyinstallerresourcesupport import resource_path server_location = "https://upload.farm" if sys.platform == 'win32': root_directory = os.path.join(os.getenv('APPDATA'),'upload.farm uploader') gifsicle_executable = resource_path(os.path.join('gifsicle','gifsicle.exe')) elif sys.platform == 'darwin': root_directory = os.path.expanduser('~/.config/upload.farm uploader') # try: # subprocess.run(['gifsicle'], shell=True) # gifsicle_executable = 'gifsicle' # except FileNotFoundError: gifsicle_executable = None else: raise ImportError os.makedirs(root_directory,exist_ok=True) backup_directory = os.path.join(root_directory,'backups') client_id = secrets.client_id client_secret = secrets.client_secret
def _create_layouts_and_widgets(self): self._table_layout = QGridLayout() self._table = QTableWidget(0,6,self) self._table_header = QHeaderView(QtCore.Qt.Horizontal) self._table_header.setSectionResizeMode(QHeaderView.ResizeToContents) # self._table_header.stretchLastSection() self._table.setHorizontalHeader(self._table_header) self._table.setHorizontalHeaderLabels(['Savegame', 'Last backed up','Auto\nbackup','Upload\nbackups','Manual\nbackup','Latest URL']) self._table.itemClicked.connect(self.item_clicked_handler) self._logo = QLabel() self._logo.setPixmap(QtGui.QPixmap(resource_path(LOGO_ICON))) self._profile_button = QPushButton("&My Account") self._profile_button.clicked.connect(self.open_acc_page) self._run_sdv_button = QPushButton("Launch &Game!") self._run_sdv_button.clicked.connect(self.run_stardew_valley) self._browse_button = QPushButton("&Backups") self._browse_button.clicked.connect(self.open_browse_backups) self._launch_gif_button = QPushButton("&Make GIFs") self._launch_gif_button.clicked.connect(self.launch_giffer) self._logout_button = QPushButton("&Logout") self._logout_button.clicked.connect(self._logout) self._exit_button = QPushButton("E&xit") self._exit_button.clicked.connect(self._icon_exit) self._help_button = QPushButton("&Help") self._help_button.clicked.connect(self.open_help) self._update_button = QPushButton("&Updates") self._update_button.clicked.connect(self.check_for_update) self._table_layout.addWidget(self._table) self._vbox = QVBoxLayout() self._hbox_title = QHBoxLayout() self._vbox_title = QVBoxLayout() self._menubar = QVBoxLayout() self._menubar1 = QHBoxLayout() self._menubar2 = QHBoxLayout() self._hbox_title.addWidget(self._logo) self._hbox_title.addStretch(1) self._hbox_title.addLayout(self._vbox_title) self._vbox_title.addLayout(self._menubar) self._vbox_title.setAlignment(QtCore.Qt.AlignTop) self._menubar.addLayout(self._menubar1) self._menubar.addLayout(self._menubar2) self._menubar1.addWidget(self._profile_button) self._menubar1.addWidget(self._run_sdv_button) self._menubar1.addWidget(self._browse_button) self._menubar1.addWidget(self._launch_gif_button) self._menubar2.addWidget(self._help_button) self._menubar2.addWidget(self._update_button) self._menubar2.addWidget(self._logout_button) self._menubar2.addWidget(self._exit_button) self._vbox.addLayout(self._hbox_title) self._vbox.addLayout(self._table_layout) self._main_widget = QWidget() self._main_widget.setLayout(self._vbox) self._main_widget.setMinimumWidth(700) self._main_widget.setMinimumHeight(500) self.setCentralWidget(self._main_widget)
def init_ui(self): self.name_of_application = "upload.farm uploader v{}".format(__version__) self.add_email_to_application_name() self.setWindowTitle(self.name_of_application) self.setWindowIcon(QtGui.QIcon(resource_path('icons/windows_icon.ico'))) self._create_layouts_and_widgets()
def set_bg_image(self): self.bgimage = QtGui.QImage(resource_path("images/bg.png")).scaled(self.size(), transformMode=QtCore.Qt.SmoothTransformation) palette = QtGui.QPalette() palette.setBrush(QtGui.QPalette.Window,QtGui.QBrush(self.bgimage)) self.setPalette(palette)
def _create_layouts_and_widgets(self): self._table_layout = QGridLayout() self._table = QTableWidget(0, 6, self) self._table_header = QHeaderView(QtCore.Qt.Horizontal) self._table_header.setSectionResizeMode(QHeaderView.ResizeToContents) # self._table_header.stretchLastSection() self._table.setHorizontalHeader(self._table_header) self._table.setHorizontalHeaderLabels([ "Savegame", "Last backed up", "Auto\nbackup", "Upload\nbackups", "Manual\nbackup", "Latest URL", ]) self._table.itemClicked.connect(self.item_clicked_handler) self._logo = QLabel() self._logo.setPixmap(QtGui.QPixmap(resource_path(LOGO_ICON))) self._profile_button = QPushButton("&My Account") self._profile_button.clicked.connect(self.open_acc_page) self._run_sdv_button = QPushButton("Launch &Game!") self._run_sdv_button.clicked.connect(self.run_stardew_valley) self._browse_button = QPushButton("&Backups") self._browse_button.clicked.connect(self.open_browse_backups) self._launch_gif_button = QPushButton("&Make GIFs") self._launch_gif_button.clicked.connect(self.launch_giffer) self._logout_button = QPushButton("&Logout") self._logout_button.clicked.connect(self._logout) self._exit_button = QPushButton("E&xit") self._exit_button.clicked.connect(self._icon_exit) self._help_button = QPushButton("&Help") self._help_button.clicked.connect(self.open_help) self._update_button = QPushButton("&Updates") self._update_button.clicked.connect(self.check_for_update) self._table_layout.addWidget(self._table) self._vbox = QVBoxLayout() self._hbox_title = QHBoxLayout() self._vbox_title = QVBoxLayout() self._menubar = QVBoxLayout() self._menubar1 = QHBoxLayout() self._menubar2 = QHBoxLayout() self._hbox_title.addWidget(self._logo) self._hbox_title.addStretch(1) self._hbox_title.addLayout(self._vbox_title) self._vbox_title.addLayout(self._menubar) self._vbox_title.setAlignment(QtCore.Qt.AlignTop) self._menubar.addLayout(self._menubar1) self._menubar.addLayout(self._menubar2) self._menubar1.addWidget(self._profile_button) self._menubar1.addWidget(self._run_sdv_button) self._menubar1.addWidget(self._browse_button) self._menubar1.addWidget(self._launch_gif_button) self._menubar2.addWidget(self._help_button) self._menubar2.addWidget(self._update_button) self._menubar2.addWidget(self._logout_button) self._menubar2.addWidget(self._exit_button) self._vbox.addLayout(self._hbox_title) self._vbox.addLayout(self._table_layout) self._main_widget = QWidget() self._main_widget.setLayout(self._vbox) self._main_widget.setMinimumWidth(700) self._main_widget.setMinimumHeight(500) self.setCentralWidget(self._main_widget)
from config import server_location, client_id, backup_directory, gifsicle_executable from ufapi import get_user_email, get_user_uploads from uploadmonitor import launch_uploadmonitor_as_thread from multiprocessing import freeze_support from addtostartup import add_to_startup, remove_from_startup, check_startup from setup import version from versioninfo import version_is_current from pyinstallerresourcesupport import resource_path from animator import AnimationThread AUTHENTICATION_URL = server_location + "/auth?client_id=" + client_id ACCOUNT_URL = server_location + "/acc" BACKUP_DIRECTORY = backup_directory RUN_STARDEW_VALLEY_STEAM = "steam://rungameid/413150" HELP_FILE_LOCATION = "file:///{}".format( os.path.abspath(resource_path("help/help.html"))) LOGO_ICON = "images/logo.png" __version__ = version # QWebEngineView = QtWebEngineWidgets.QWebEngineView QWidget = QtWidgets.QWidget QMainWindow = QtWidgets.QMainWindow Signal = QtCore.pyqtSignal QApplication = QtWidgets.QApplication QLabel = QtWidgets.QLabel QHBoxLayout = QtWidgets.QHBoxLayout QVBoxLayout = QtWidgets.QVBoxLayout QTextEdit = QtWidgets.QTextEdit QCheckBox = QtWidgets.QCheckBox QDoubleSpinBox = QtWidgets.QDoubleSpinBox QPushButton = QtWidgets.QPushButton
def init_ui(self): self.name_of_application = "upload.farm giffer" self.setWindowTitle(self.name_of_application) self.setWindowIcon(QtGui.QIcon(resource_path('icons/windows_icon.ico'))) self._create_layouts_and_widgets() self.show()
import glob from urllib.parse import urljoin import subprocess import sys from math import log import requests # import imageio from PIL import Image, ImageFont, ImageDraw from PyQt5 import QtCore from ufapi import get_series_info from config import root_directory, server_location, gifsicle_executable from pyinstallerresourcesupport import resource_path FONT_PATH = resource_path('fonts/VT323.ttf') FINAL_PANEL_MULTIPLIER = 4 class AnimationThread(QtCore.QRunnable): def __init__(self,name,url,signal=None,**kwargs): super().__init__() self.name = name self.url = url self.signal = signal self.kwargs = kwargs self.button = kwargs.get('button') def run(self): filename = make_animation(self.name,self.url,**self.kwargs) if self.signal:
from watcherlib import Watcher, manual_process from config import server_location, client_id, backup_directory from ufapi import get_user_email from uploadmonitor import launch_uploadmonitor_as_thread from multiprocessing import freeze_support from addtostartup import add_to_startup, remove_from_startup, check_startup from setup import version from versioninfo import version_is_current from pyinstallerresourcesupport import resource_path AUTHENTICATION_URL = server_location + "/auth?client_id=" + client_id ACCOUNT_URL = server_location + "/acc" BACKUP_DIRECTORY = backup_directory RUN_STARDEW_VALLEY_STEAM = 'steam://rungameid/413150' HELP_FILE_LOCATION = "file:///{}".format( os.path.abspath(resource_path("help/help.html"))) LOGO_ICON = resource_path("images/logo.png") __version__ = version # QWebEngineView = QtWebEngineWidgets.QWebEngineView QWidget = QtWidgets.QWidget QMainWindow = QtWidgets.QMainWindow Signal = QtCore.pyqtSignal QApplication = QtWidgets.QApplication QLabel = QtWidgets.QLabel QHBoxLayout = QtWidgets.QHBoxLayout QVBoxLayout = QtWidgets.QVBoxLayout QTextEdit = QtWidgets.QTextEdit QPushButton = QtWidgets.QPushButton QGridLayout = QtWidgets.QGridLayout QHeaderView = QtWidgets.QHeaderView