def __init__(self, parent=None, title=None): QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates)) super(DAQ_Analysis, self).__init__() if parent is None: raise Exception('no valid parent container, expected dockarea') # parent=DockArea() # exit(0) self.dockarea = parent self.mainwindow = parent.parent() if title is None: title = 'DAQ_Analysis' self.title = title self.mainwindow.setWindowTitle(self.title) self.wait_time = 2000 self.h5file = None self.loaded_data = None self.loaded_data_scan_type = None self.x_axis = None self.y_axis = None self.data_buffer = [] # convenience list to store data to be displayed self.ui = QObject() # the user interface self.set_GUI()
def setUp(self): self.setUpQuamash() QLocale.setDefault(QLocale("en_GB")) self.identities_registry = Mock(spec='sakia.core.registry.IdentitiesRegistry') self.community = Mock(spec='sakia.core.Community') self.community.name = "test_brouzouf" self.community.bma_access = Mock(spec='sakia.core.net.api.bma.BmaAccess')
def __init__(self, parent=None): QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates)) super(ViewerND, self).__init__() # if parent is None: # raise Exception('no valid parent container, expected dockarea') # parent=DockArea() # exit(0) if parent is None: parent = QtWidgets.QWidget() parent.show() self.parent = parent self.wait_time = 2000 self.viewer_type = 'DataND' # ☺by default but coul dbe used for 3D visualization self.x_axis = dict(data=None, label='', units='') self.y_axis = dict(data=None, label='', units='') self.data_buffer = [ ] # convenience list to store 0D data to be displayed self.datas = None self.datas_settings = None # set default data shape case self.axes_nav = None self.data_axes = None # self.set_nav_axes(3) self.ui = QObject() # the user interface self.set_GUI()
def __init__(self, scanner_items=OrderedDict([]), scan_type = 'Scan1D'): """ Parameters ---------- parent scanner_items: (items used by ScanSelector for chosing scan area or linear traces) """ QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates)) super(Scanner, self).__init__() self.settings_tree = None self.setupUI() self.scan_selector = ScanSelector(scanner_items, scan_type) self.settings.child('scan_options', 'scan1D_settings').setValue(scan_type) #self.scan_selector.settings.child('scan_options', 'scan_type').hide() self.scan_selector.scan_select_signal.connect(self.update_scan_2D_positions) self.settings.child('scan_options', 'scan1D_settings', 'scan1D_roi_module').setOpts( limits=self.scan_selector.sources_names) self.settings.child('scan_options', 'scan2D_settings', 'scan2D_roi_module').setOpts( limits=self.scan_selector.sources_names) self.scan_selector.widget.setVisible(False) self.scan_selector.show_scan_selector(visible=False) self.set_scan()
def setUp(self): self.setUpQuamash() QLocale.setDefault(QLocale("en_GB")) self.identities_registry = IdentitiesRegistry({}) self.application = Application(self.qapplication, self.lp, self.identities_registry) self.application.preferences['notifications'] = False self.endpoint = BMAEndpoint(PyBMAEndpoint("", "127.0.0.1", "", 50000)) self.node = Node("test_currency", [self.endpoint], "", "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk", nice_blockchain.bma_blockchain_current, Node.ONLINE, time.time(), {}, "ucoin", "0.14.0", 0) self.network = Network.create(self.node) self.bma_access = BmaAccess.create(self.network) self.community = Community("test_currency", self.network, self.bma_access) self.wallet = Wallet(0, "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ", "Wallet 1", self.identities_registry) self.wallet.init_cache(self.application, self.community) # Salt/password : "******" # Pubkey : 7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ self.account = Account("testsakia", "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ", "john", [self.community], [self.wallet], [], self.identities_registry)
def __init__(self, area, detector_modules=[], actuator_modules=[]): QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates)) super(DAQ_PID, self).__init__() self.settings = Parameter.create(title='PID settings', name='pid_settings', type='group', children=params) self.title = 'PyMoDAQ PID' self.Initialized_state = False self.model_class = None self.detector_modules = detector_modules self.actuator_modules = actuator_modules self.dock_area = area self.overshoot = None self.check_moving = False self.preset_manager = PresetManager() self.setupUI() self.command_stage.connect( self.move_Abs ) #to be compatible with actuator modules within daq scan self.enable_controls_pid(False) self.enable_controls_pid_run(False)
def __init__(self, persepolis_setting): super().__init__() icon = QIcon() self.persepolis_setting = persepolis_setting # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) self.setWindowIcon( QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) self.setWindowTitle( QCoreApplication.translate("setting_ui_tr", 'Preferences')) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) global icons icons = ':/' + str( self.persepolis_setting.value('settings/icons')) + '/' window_verticalLayout = QVBoxLayout(self) self.pressKeyLabel = QLabel(self) window_verticalLayout.addWidget(self.pressKeyLabel) self.capturedKeyLabel = QLabel(self) window_verticalLayout.addWidget(self.capturedKeyLabel) # window buttons buttons_horizontalLayout = QHBoxLayout() buttons_horizontalLayout.addStretch(1) self.cancel_pushButton = QPushButton(self) self.cancel_pushButton.setIcon(QIcon(icons + 'remove')) buttons_horizontalLayout.addWidget(self.cancel_pushButton) self.ok_pushButton = QPushButton(self) self.ok_pushButton.setIcon(QIcon(icons + 'ok')) buttons_horizontalLayout.addWidget(self.ok_pushButton) window_verticalLayout.addLayout(buttons_horizontalLayout) # labels self.pressKeyLabel.setText( QCoreApplication.translate("setting_ui_tr", "Press new keys")) self.cancel_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "Cancel")) self.ok_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "OK"))
def _main() -> None: """ Execute the main application loop. :return: nothing :rtype: None """ app = QApplication(sys.argv) QLocale.setDefault(QLocale.c()) # translation language = QLocale.system().name()[:2] translations_path = QLibraryInfo.location(QLibraryInfo.TranslationsPath) base_translator = QTranslator() base_translator.load("qtbase_{}".format(language), translations_path) app.installTranslator(base_translator) custom_translator = QTranslator() custom_translator.load("cafog_{}".format(language)) app.installTranslator(custom_translator) # generate main window frame = MainWindow() frame.show() sys.exit(app.exec_())
def setUp(self): self.setUpQuamash() QLocale.setDefault(QLocale("en_GB")) self.identity = Mock(spec='sakia.core.registry.Identity') self.identity.pubkey = "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk" self.identity.uid = "A" self.app = MagicMock(autospec='sakia.core.Application') self.account_joe = Mock(spec='sakia.core.Account') self.account_joe.contacts_changed = Mock() self.account_joe.contacts_changed.disconnect = Mock() self.account_joe.contacts_changed.connect = Mock() self.account_doe = Mock(spec='sakia.core.Account') self.account_doe.contacts_changed = Mock() self.account_doe.contacts_changed.disconnect = Mock() self.account_doe.contacts_changed.connect = Mock() def change_current_account(account_name): type(self.app).current_account = PropertyMock(return_value=self.account_doe) self.app.get_account = Mock(side_effect=lambda name: self.app.accounts[name]) self.app.change_current_account = Mock(side_effect=change_current_account) type(self.app).current_account = PropertyMock(return_value=self.account_joe) self.app.accounts = {'joe':self.account_joe, 'doe': self.account_doe} self.homescreen = MagicMock(autospec='sakia.gui.homescreen.Homescreen') self.community_view = MagicMock(autospec='sakia.gui.community_view.CommunityView') self.password_asker = MagicMock(autospec='sakia.gui.password_asker.PasswordAsker') self.node_manager = MagicMock(autospec='sakia.gui.node_manager.NodeManager')
def setUp(self): self.setUpQuamash() QLocale.setDefault(QLocale("en_GB")) self.application = Application(self.qapplication, self.lp, IdentitiesRegistry()) self.main_window = MainWindow.startup(self.application)
def setUp(self): self.setUpQuamash() QLocale.setDefault(QLocale("en_GB")) self.identities_registry = IdentitiesRegistry({}) self.application = Application(self.qapplication, self.lp, self.identities_registry) self.application.preferences['notifications'] = False self.endpoint = BMAEndpoint("", "127.0.0.1", "", 50005) self.node = Node("test_currency", [self.endpoint], "", "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk", nice_blockchain.bma_blockchain_current, Node.ONLINE, time.time(), {}, "duniter", "0.14.0", 0) self.network = Network.create(self.node) self.bma_access = BmaAccess.create(self.network) self.community = Community("test_currency", self.network, self.bma_access) self.wallet = Wallet(0, "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ", "Wallet 1", self.identities_registry) self.wallet.init_cache(self.application, self.community) # Salt/password : "******" # Pubkey : 7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ self.account = Account("testsakia", "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ", "john", [self.community], [self.wallet], [], self.identities_registry)
def setUp(self): self.setUpQuamash() QLocale.setDefault(QLocale("en_GB")) self.identities_registry = IdentitiesRegistry() self.application = Application(self.qapplication, self.lp, self.identities_registry) self.application.preferences['notifications'] = False self.mock_nice_blockchain = nice_blockchain.get_mock(self.lp) self.node = Node(self.mock_nice_blockchain.peer(), "", "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk", None, Node.ONLINE, time.time(), {}, "ucoin", "0.14.0", 0) self.network = Network.create(self.node) self.bma_access = BmaAccess.create(self.network) self.community = Community("test_currency", self.network, self.bma_access) self.wallet = Wallet(0, "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ", "Wallet 1", self.identities_registry) # Salt/password : "******" # Pubkey : 7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ self.account = Account("testsakia", "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ", "john", [self.community], [self.wallet], [], self.identities_registry) self.password_asker = PasswordAskerDialog(self.account) self.password_asker.password = "******" self.password_asker.remember = True
def __init__(self, parent, h5file=None): QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates)) super(H5Browser, self).__init__() if not (isinstance(parent, QtWidgets.QWidget) or isinstance(parent, QtWidgets.QMainWindow)): raise Exception( 'no valid parent container, expected a QWidget or a QMainWindow' ) self.h5file = None if isinstance(parent, QtWidgets.QMainWindow): self.main_window = parent self.parent = QtWidgets.QWidget() self.main_window.setCentralWidget(self.parent) else: self.main_window = None self.parent = parent self.ui = QObject() # the user interface self.set_GUI() self.load_file(h5file) self.ui.h5file_tree.ui.Open_Tree.click()
def __init__(self, parent, items_list=[], preset_items=[]): QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates)) super(custom_list_widget, self).__init__() self.parent = parent self.setDragEnabled(True) self.setDragDropMode(QAbstractItemView.DragDrop) self.setToolTip('list of scan items')
def setUp(self): self.setUpQuamash() QLocale.setDefault(QLocale("en_GB")) self.identities_registry = IdentitiesRegistry() self.application = Application(self.qapplication, self.lp, self.identities_registry) self.application.preferences['notifications'] = False self.peer = Peer.from_signed_raw("""Version: 2 Type: Peer Currency: meta_brouzouf PublicKey: 8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU Block: 48698-000005E0F228038E4DDD4F6CA4ACB01EC88FBAF8 Endpoints: BASIC_MERKLED_API duniter.inso.ovh 80 82o1sNCh1bLpUXU6nacbK48HBcA9Eu2sPkL1/3c2GtDPxBUZd2U2sb7DxwJ54n6ce9G0Oy7nd1hCxN3fS0oADw== """) self.node = Node(self.peer, "", "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk", None, Node.ONLINE, time.time(), {}, "duniter", "0.12.0", 0, Mock("aiohttp.ClientSession")) self.network = Network.create(self.node) self.bma_access = BmaAccess.create(self.network) self.community = Community("test_currency", self.network, self.bma_access)
def __init__(self, parent, dict, persepolis_setting): super().__init__(persepolis_setting) self.persepolis_setting = persepolis_setting self.dict = dict self.parent = parent # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # connecting buttons self.open_pushButtun.clicked.connect(self.openFile) self.open_folder_pushButtun.clicked.connect(self.openFolder) self.ok_pushButton.clicked.connect(self.okButtonPressed) # labels # find gid gid = self.dict['gid'] # get file_path from data base self.add_link_dict = self.parent.persepolis_db.searchGidInAddLinkTable(gid) file_path = self.add_link_dict['download_path'] # save_as self.save_as_lineEdit.setText(file_path) self.save_as_lineEdit.setToolTip(file_path) # link link = str(self.dict['link']) self.link_lineEdit.setText(link) self.link_lineEdit.setToolTip(link) # file_name window_title = str(self.dict['file_name']) file_name = QCoreApplication.translate("after_download_src_ui_tr", "<b>File name</b>: ") + \ window_title self.setWindowTitle(window_title) self.file_name_label.setText(file_name) # size size = QCoreApplication.translate("after_download_src_ui_tr", "<b>Size</b>: ") + str(self.dict['size']) self.size_label.setText(size) # disable link_lineEdit and save_as_lineEdit self.link_lineEdit.setEnabled(False) self.save_as_lineEdit.setEnabled(False) # set window size and position size = self.persepolis_setting.value( 'AfterDownloadWindow/size', QSize(570, 290)) position = self.persepolis_setting.value( 'AfterDownloadWindow/position', QPoint(300, 300)) self.resize(size) self.move(position)
def translate(self, app): QLocale.setDefault(QLocale(self._preferences.locale)) for resource in ("qtbase", "tgit"): translator = QTranslator(app) if translator.load( "{0}_{1}".format(resource, self._preferences.locale), ":/"): app.installTranslator(translator)
def __init__(self, parent, gid, persepolis_setting): super().__init__(persepolis_setting) self.persepolis_setting = persepolis_setting self.parent = parent self.gid = gid self.status = None self.resume_pushButton.clicked.connect(self.resumePushButtonPressed) self.stop_pushButton.clicked.connect(self.stopPushButtonPressed) self.pause_pushButton.clicked.connect(self.pausePushButtonPressed) self.download_progressBar.setValue(0) self.limit_pushButton.clicked.connect(self.limitPushButtonPressed) self.limit_frame.setEnabled(False) self.limit_checkBox.toggled.connect(self.limitCheckBoxToggled) self.after_frame.setEnabled(False) self.after_checkBox.toggled.connect(self.afterCheckBoxToggled) self.after_pushButton.clicked.connect(self.afterPushButtonPressed) # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # check if limit speed actived by user or not add_link_dictionary = self.parent.persepolis_db.searchGidInAddLinkTable( gid) limit = str(add_link_dictionary['limit_value']) if limit != '0': limit_number = limit[:-1] limit_unit = limit[-1] self.limit_spinBox.setValue(float(limit_number)) if limit_unit == 'K': self.after_comboBox.setCurrentIndex(0) else: self.after_comboBox.setCurrentIndex(1) self.limit_checkBox.setChecked(True) self.after_comboBox.currentIndexChanged.connect( self.afterComboBoxChanged) self.limit_comboBox.currentIndexChanged.connect( self.limitComboBoxChanged) self.limit_spinBox.valueChanged.connect(self.limitComboBoxChanged) # set window size and position size = self.persepolis_setting.value('ProgressWindow/size', QSize(595, 274)) position = self.persepolis_setting.value('ProgressWindow/position', QPoint(300, 300)) self.resize(size) self.move(position)
def setUp(self): self.setUpQuamash() QLocale.setDefault(QLocale("en_GB")) self.identities_registry = Mock( spec='sakia.core.registry.IdentitiesRegistry') self.community = Mock(spec='sakia.core.Community') self.community.name = "test_brouzouf" self.community.bma_access = Mock( spec='sakia.core.net.api.bma.BmaAccess')
def switch_language(self): translator = QTranslator(self.qapp) logging.debug("Loading translations") locale = self.preferences["lang"] QLocale.setDefault(QLocale(locale)) if translator.load(":/i18n/{0}".format(locale)): if QCoreApplication.installTranslator(translator): logging.debug("Loaded i18n/{0}".format(locale)) else: logging.debug("Couldn't load translation")
def __init__(self): self.initialized = False self.app_path = '' # will be passed in the init method self.log_level_str = 'WARNING' self.app_version = '' QLocale.setDefault(self.get_default_locale()) self.date_format = self.get_default_locale().dateFormat(QLocale.ShortFormat) self.date_time_format = self.get_default_locale().dateTimeFormat(QLocale.ShortFormat) # List of Dash network configurations. Multiple conn configs advantage is to give the possibility to use # another config if particular one is not functioning (when using "public" RPC service, it could be node's # maintanance) self.dash_net_configs = [] # to distribute the load evenly over "public" RPC services, we choose radom connection (from enabled ones) # if it is set to False, connections will be used accoording to its order in dash_net_configs list self.random_dash_net_config = True # list of all enabled dashd configurations (DashNetworkConnectionCfg) - they will be used accourding to # the order in list self.active_dash_net_configs = [] # list of misbehaving dash network configurations - they will have the lowest priority during next # connections self.defective_net_configs = [] self.hw_type = HWType.trezor # TREZOR, KEEPKEY, LEDGERNANOS self.hw_keepkey_psw_encoding = 'NFC' # Keepkey passphrase UTF8 chars encoding: # NFC: compatible with official Keepkey client app # NFKD: compatible with Trezor self.block_explorer_tx = 'https://chainz.cryptoid.info/dash/tx.dws?%TXID%' self.block_explorer_addr = 'https://chainz.cryptoid.info/dash/address.dws?%ADDRESS%' self.dash_central_proposal_api = 'https://www.dashcentral.org/api/v1/proposal?hash=%HASH%' self.check_for_updates = True self.backup_config_file = True self.read_proposals_external_attributes = True # if True, some additional attributes will be downloaded from # external sources self.dont_use_file_dialogs = False self.confirm_when_voting = True self.add_random_offset_to_vote_time = True # To avoid identifying one user's masternodes by vote time self.csv_delimiter =';' self.masternodes = [] self.last_bip32_base_path = '' self.bip32_recursive_search = True self.modified = False self.cache_dir = '' self.app_config_file_name = '' self.log_dir = '' self.log_file = '' self.log_level_str = '' self.db_cache_file_name = '' self.cfg_backup_dir = '' self.app_last_version = ''
def __init__(self, parent, gid, persepolis_setting): super().__init__(persepolis_setting) self.persepolis_setting = persepolis_setting self.parent = parent self.gid = gid self.status = None self.resume_pushButton.clicked.connect(self.resumePushButtonPressed) self.stop_pushButton.clicked.connect(self.stopPushButtonPressed) self.pause_pushButton.clicked.connect(self.pausePushButtonPressed) self.download_progressBar.setValue(0) self.limit_pushButton.clicked.connect(self.limitPushButtonPressed) self.limit_frame.setEnabled(False) self.limit_checkBox.toggled.connect(self.limitCheckBoxToggled) self.after_frame.setEnabled(False) self.after_checkBox.toggled.connect(self.afterCheckBoxToggled) self.after_pushButton.clicked.connect(self.afterPushButtonPressed) # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # check if limit speed actived by user or not add_link_dictionary = self.parent.persepolis_db.searchGidInAddLinkTable(gid) limit = str(add_link_dictionary['limit_value']) if limit != '0': limit_number = limit[:-1] limit_unit = limit[-1] self.limit_spinBox.setValue(float(limit_number)) if limit_unit == 'K': self.after_comboBox.setCurrentIndex(0) else: self.after_comboBox.setCurrentIndex(1) self.limit_checkBox.setChecked(True) self.after_comboBox.currentIndexChanged.connect(self.afterComboBoxChanged) self.limit_comboBox.currentIndexChanged.connect(self.limitComboBoxChanged) self.limit_spinBox.valueChanged.connect(self.limitComboBoxChanged) # set window size and position size = self.persepolis_setting.value( 'ProgressWindow/size', QSize(595, 274)) position = self.persepolis_setting.value( 'ProgressWindow/position', QPoint(300, 300)) self.resize(size) self.move(position)
def initial_setup_application(app: QApplication): # global settings QCoreApplication.setApplicationName(APPNAME) QCoreApplication.setOrganizationName(ORGNAME) QLocale.setDefault(QLocale(QLocale.French, QLocale.France)) app.setWindowIcon(QIcon(":/icons/mycartable.png")) QFontDatabase.addApplicationFont(":/fonts/Verdana.ttf") QFontDatabase.addApplicationFont(":/fonts/Code New Roman.otf") QFontDatabase.addApplicationFont(":/fonts/LiberationMono-Regular.ttf")
def setUp(self): self.setUpQuamash() QLocale.setDefault(QLocale("en_GB")) self.identity = Mock(specs='sakia.core.registry.Identity') self.identity.pubkey = "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk" self.identity.uid = "A" self.app = MagicMock(specs='sakia.core.Application') self.account = MagicMock(specs='sakia.core.Account') self.community = MagicMock(specs='sakia.core.Community') self.password_asker = MagicMock(specs='sakia.gui.password_asker.PasswordAsker')
def __init__(self,parent=None,dock=None): """ """ QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates)) super(Viewer0D,self).__init__() if parent is None: parent=QtWidgets.QWidget() self.ui=Ui_Form() self.ui.setupUi(parent) #self.dockarea=parent #if dock is not None: # self.ui.viewer_dock = dock # self.ui.viewer_dock.setTitle("0DViewer") #else: # self.ui.viewer_dock = Dock("0DViewer", size=(1, 1)) ## give this dock the minimum possible size # self.dockarea.addDock(self.ui.viewer_dock) #self.ui.viewer_dock.addWidget(widget_viewer) self.ui.statusbar=QtWidgets.QStatusBar(parent) self.ui.statusbar.setMaximumHeight(15) self.ui.StatusBarLayout.addWidget(self.ui.statusbar) self.ui.status_message=QtWidgets.QLabel() self.ui.status_message.setMaximumHeight(15) self.ui.statusbar.addWidget(self.ui.status_message) self.ui.xaxis_item=self.ui.Graph1D.plotItem.getAxis('bottom') self._labels = [] self.viewer_type='Data0D' self.wait_time=1000 self.plot_channels=None self.plot_colors=['r', 'g','b', 'c', 'm', 'y', 'k',' w'] self.Nsamples=self.ui.Nhistory_sb.value() self.x_axis=np.linspace(0,self.Nsamples-1,self.Nsamples) self.datas=[] #datas on each channel. list of 1D arrays self.legend=self.ui.Graph1D.plotItem.addLegend() self.data_to_export=OrderedDict(data0D=OrderedDict(),data1D=None,data2D=None) self.list_items=None ##Connecting buttons: self.ui.clear_pb.clicked.connect(self.clear_data) self.ui.Nhistory_sb.valueChanged.connect(self.update_x_axis) self.ui.show_datalist_pb.clicked.connect(self.show_data_list) self.show_data_list(False)
def loadLanguage(self, language): if not self.language == language: self.language = language locale = QLocale(language) QLocale.setDefault(locale) self.switchTranslator(self.qtTl, "qtbase", language) self.switchTranslator(self.appTl, "wuchshuellenrechner", language) # update gui self.retranslateUi() self.dataWidget.retranslateUi()
def switch_language(self): logging.debug("Loading translations") locale = self.preferences['lang'] QLocale.setDefault(QLocale(locale)) QCoreApplication.removeTranslator(self._translator) self._translator = QTranslator(self.qapp) if locale == "en_GB": QCoreApplication.installTranslator(self._translator) elif self._translator.load(":/i18n/{0}".format(locale)): if QCoreApplication.installTranslator(self._translator): logging.debug("Loaded i18n/{0}".format(locale)) else: logging.debug("Couldn't load translation")
def setUp(self): self.setUpQuamash() QLocale.setDefault(QLocale("en_GB")) self.identity = Mock(specs='sakia.core.registry.Identity') self.identity.pubkey = "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk" self.identity.uid = "A" self.app = MagicMock(specs='sakia.core.Application') self.account = MagicMock(specs='sakia.core.Account') self.community = MagicMock(specs='sakia.core.Community') self.password_asker = MagicMock( specs='sakia.gui.password_asker.PasswordAsker')
def __init__(self, **kwds): super().__init__(**kwds) self.qt_translator = QTranslator(QCoreApplication.instance()) try: self.qt_dir = os.environ["QTDIR"] except: if sys.platform == "win32": self.qt_dir = os.path.join(sys.exec_prefix, "share", "qt5") else: self.qt_dir = os.path.join("/usr", "share", "qt5") # Avoid stuff like Thai numerals if the language is not explicitly # set to Thai. QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates))
def setup_gettext(localedir, ui_language=None, logger=None): """Setup locales, load translations, install gettext functions.""" if not logger: logger = lambda *a, **b: None # noqa: E731 current_locale = '' try: if ui_language: current_locale = locale.normalize(ui_language + '.' + locale.getpreferredencoding()) locale.setlocale(locale.LC_ALL, current_locale) else: current_locale = _init_default_locale() except Exception as e: logger(e) os.environ['LANGUAGE'] = os.environ['LANG'] = current_locale QLocale.setDefault(QLocale(current_locale)) logger("Using locale %r", current_locale) try: logger("Loading gettext translation, localedir=%r", localedir) trans = gettext.translation("picard", localedir) logger("Loading gettext translation (picard-countries), localedir=%r", localedir) trans_countries = gettext.translation("picard-countries", localedir) logger("Loading gettext translation (picard-attributes), localedir=%r", localedir) trans_attributes = gettext.translation("picard-attributes", localedir) except OSError as e: logger(e) trans = gettext.NullTranslations() trans_countries = gettext.NullTranslations() trans_attributes = gettext.NullTranslations() trans.install(['ngettext']) builtins.__dict__['gettext_countries'] = trans_countries.gettext builtins.__dict__['gettext_attributes'] = trans_attributes.gettext if hasattr(trans_attributes, 'pgettext'): builtins.__dict__['pgettext_attributes'] = trans_attributes.pgettext else: def pgettext(context, message): return gettext_ctxt(trans_attributes.gettext, message, context) builtins.__dict__['pgettext_attributes'] = pgettext logger("_ = %r", _) logger("N_ = %r", N_) logger("ngettext = %r", ngettext) logger("gettext_countries = %r", gettext_countries) logger("gettext_attributes = %r", gettext_attributes) logger("pgettext_attributes = %r", pgettext_attributes)
def setUp(self): self.setUpQuamash() QLocale.setDefault(QLocale("en_GB")) self.identities_registry = IdentitiesRegistry({}) self.application = Application(self.qapplication, self.lp, self.identities_registry) self.application.preferences['notifications'] = False # Salt/password : "******" # Pubkey : 7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ self.account = Account("testsakia", "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ", "john", [], [], [], self.identities_registry) self.password_asker = PasswordAskerDialog(self.account) self.password_asker.password = "******" self.password_asker.remember = True
def main(): locale = QLocale(QLocale.C) locale.setNumberOptions(QLocale.RejectGroupSeparator) QLocale.setDefault(locale) config = Config() config.removeOldFiles() app = QApplication([]) window = MainWindow() window.show() sys.exit(app.exec_())
def __init__(self, dockarea): QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates)) super(CustomApp, self).__init__() if not isinstance(dockarea, DockArea): raise Exception('no valid parent container, expected a DockArea') self.dockarea = dockarea self.mainwindow = dockarea.parent() # init the object parameters self.detector = None self.raw_data = [] # init the user interface self.setup_UI()
def setUp(self): self.setUpQuamash() QLocale.setDefault(QLocale("en_GB")) self.identities_registry = IdentitiesRegistry({}) self.application = Application(self.qapplication, self.lp, self.identities_registry) self.application.preferences['notifications'] = False # Salt/password : "******" # Pubkey : 7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ self.account = Account("testsakia", "B7J4sopyfqzi3uh4Gzsdnp1XHc87NaxY7rqW2exgivCa", "test", [], [], [], self.identities_registry) self.password_asker = PasswordAskerDialog(self.account) self.password_asker.password = "******" self.password_asker.remember = True
def __init__(self, parent): QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates)) super(Ui_Form, self).__init__() self.ui = Ui_Form() self.ui.setupUi(parent) self.widg = QtWidgets.QWidget() self.fourierfilt = FourierFilterer(self.widg) self.ui.splitter_2.addWidget(self.widg) self.ui.graph1D = self.fourierfilt.viewer1D.plotwidget QtWidgets.QApplication.processEvents() self.ui.splitter.setSizes([200, 400]) self.ui.statusbar = QtWidgets.QStatusBar(parent) self.ui.statusbar.setMaximumHeight(15) self.ui.StatusBarLayout.addWidget(self.ui.statusbar) self.wait_time = 1000 self.parent = parent self.xdata = None self.ydata = None self.measurement_types = Measurement_type.names() self.measurement_type = Measurement_type(0) self.ui.measurement_type_combo.clear() self.ui.measurement_type_combo.addItems(self.measurement_types) self.ui.fit_curve = self.fourierfilt.viewer1D.plotwidget.plot() self.ui.fit_curve.setPen("y") self.ui.fit_curve.setVisible(False) self.ui.selected_region = self.fourierfilt.viewer1D.ROI self.ui.selected_region.setZValue(-10) self.ui.selected_region.setBrush('b') self.ui.selected_region.setOpacity(0.2) self.ui.selected_region.setVisible(True) self.fourierfilt.viewer1D.plotwidget.addItem(self.ui.selected_region) ##Connecting buttons: self.ui.Quit_pb.clicked.connect(self.Quit_fun, type=Qt.QueuedConnection) self.ui.measurement_type_combo.currentTextChanged[str].connect( self.update_measurement_subtype) self.ui.measure_subtype_combo.currentTextChanged[str].connect( self.update_measurement) self.update_measurement_subtype( self.ui.measurement_type_combo.currentText(), update=False) self.ui.selected_region.sigRegionChanged.connect( self.update_measurement) self.ui.result_sb.valueChanged.connect(self.ui.result_lcd.display)
def startmain(): """ Initialise the application and display the main window. """ args = parse_arguments() app = QApplication(sys.argv) app.cleanup_files = [] if not args.native_style: app.setStyle(QStyleFactory.create('Fusion')) app.setPalette(QApplication.style().standardPalette()) app_icon = QIcon(':/icons/ui/ot_icon.svg') print(app_icon.isNull(), app_icon.pixmap(200, 200).isNull()) app.setApplicationName(APP_NAME) app.setApplicationVersion(VERSION_STRING) app.setOrganizationName(ORG_NAME) app.setWindowIcon(app_icon) print('AppName: {0:s}'.format(app.applicationName())) print('AppVersion: {0:s}'.format(app.applicationVersion())) print('Company Name: {0:s}'.format(app.organizationName())) QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedKingdom)) # Add passed arguments to app. app.args = args print('Args:', app.args) # Check to see if application already running. existing_pid = instance_check(app) if existing_pid: print(existing_pid) if app.args.quit_existing: # Command line argument passed to close existing program. Do that, then quit. if platform.system() == "Windows": subprocess.Popen("taskkill /F /T /PID %i" % existing_pid, shell=True) else: os.killpg(existing_pid, signal.SIGKILL) else: message_box_error('Program already running.', 'You can only have one copy of the Bing Wallpaper Changer running at once.') sys.exit() mainwindow = MainWindow() # mainwindow.show() sys.exit(app.exec_())
def main(): # prepare application app = QtWidgets.QApplication(sys.argv) QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates)) prepareImports() registerControllers() registerViewers() loadResources() # start application app_ctrl = AppController() features.Provide(AppController.__name__, app_ctrl) app_ctrl.showMaximized() sys.exit(app.exec_())
def __init__(self, data, header, editable=True, parent=None): QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates)) super().__init__(parent) if isinstance(data, np.ndarray): data_tot = [] for dat in data: data_tot.append([float(d) for d in dat]) data = data_tot self._data = data #stored data as a list of list self.data_tmp = None self.header = header if not isinstance(editable, list): self.editable = [editable for h in header] else: self.editable = editable
def setUp(self): self.setUpQuamash() QLocale.setDefault(QLocale("en_GB")) self.identities_registry = IdentitiesRegistry() self.application = Application(self.qapplication, self.lp, self.identities_registry) self.application.preferences['notifications'] = False self.endpoint = BMAEndpoint("", "127.0.0.1", "", 50000) self.node = Node("test_currency", [self.endpoint], "", "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk", None, Node.ONLINE, time.time(), {}, "ucoin", "0.12.0", 0) self.network = Network.create(self.node) self.bma_access = BmaAccess.create(self.network) self.community = Community("test_currency", self.network, self.bma_access)
def setUp(self): self.setUpQuamash() QLocale.setDefault(QLocale("en_GB")) self.account_identity = Mock(specs='core.registry.Identity') self.account_identity.pubkey = "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk" self.account_identity.uid = "account_identity" self.account_identity.is_member = CoroutineMock(spec='core.registry.Identity.is_member', return_value=True) self.first_identity = Mock(specs='core.registry.Identity') self.first_identity.pubkey = "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ" self.first_identity.uid = "first_identity" self.first_identity.is_member = CoroutineMock(spec='core.registry.Identity.is_member', return_value=True) self.second_identity = Mock(specs='core.registry.Identity') self.second_identity.pubkey = "FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn" self.second_identity.uid = "second_uid" self.second_identity.is_member = CoroutineMock(spec='core.registry.Identity.is_member', return_value=False)
def __init__(self, persepolis_setting): super().__init__() self.persepolis_setting = persepolis_setting icons = ':/' + \ str(self.persepolis_setting.value('settings/icons')) + '/' # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) self.setWindowIcon(QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) window_verticalLayout = QVBoxLayout() self.setLayout(window_verticalLayout) # queue_tabWidget self.queue_tabWidget = QTabWidget(self) window_verticalLayout.addWidget(self.queue_tabWidget) # links_tab self.links_tab = QWidget() links_tab_verticalLayout = QVBoxLayout(self.links_tab) # link table self.links_table = QTableWidget(self.links_tab) links_tab_verticalLayout.addWidget(self.links_table) self.links_table.setSelectionBehavior(QAbstractItemView.SelectRows) self.links_table.setEditTriggers(QAbstractItemView.NoEditTriggers) self.links_table.verticalHeader().hide() self.links_table.setColumnCount(3) links_table_header_labels = [ 'File Name', 'Download Link', 'dictionary'] self.links_table.setHorizontalHeaderLabels(links_table_header_labels) self.links_table.setColumnHidden(2, True) self.links_table.horizontalHeader().setSectionResizeMode(0) self.links_table.horizontalHeader().setStretchLastSection(True) # add_queue add_queue_horizontalLayout = QHBoxLayout() self.select_all_pushButton = QPushButton(self.links_tab) add_queue_horizontalLayout.addWidget(self.select_all_pushButton) self.deselect_all_pushButton = QPushButton(self.links_tab) add_queue_horizontalLayout.addWidget(self.deselect_all_pushButton) add_queue_horizontalLayout.addStretch(1) self.add_queue_label = QLabel(self.links_tab) add_queue_horizontalLayout.addWidget(self.add_queue_label) self.add_queue_comboBox = QComboBox(self.links_tab) add_queue_horizontalLayout.addWidget(self.add_queue_comboBox) links_tab_verticalLayout.addLayout(add_queue_horizontalLayout) links_tab_verticalLayout.addStretch(1) self.queue_tabWidget.addTab(self.links_tab, "") # options_tab self.options_tab = QWidget() options_tab_verticalLayout = QVBoxLayout(self.options_tab) # proxy proxy_verticalLayout = QVBoxLayout() self.proxy_checkBox = QCheckBox(self.options_tab) proxy_verticalLayout.addWidget(self.proxy_checkBox) self.proxy_frame = QFrame(self.options_tab) self.proxy_frame.setFrameShape(QFrame.StyledPanel) self.proxy_frame.setFrameShadow(QFrame.Raised) proxy_gridLayout = QGridLayout(self.proxy_frame) self.ip_lineEdit = QLineEdit(self.proxy_frame) self.ip_lineEdit.setInputMethodHints(QtCore.Qt.ImhNone) proxy_gridLayout.addWidget(self.ip_lineEdit, 0, 1, 1, 1) self.proxy_pass_label = QLabel(self.proxy_frame) proxy_gridLayout.addWidget(self.proxy_pass_label, 2, 2, 1, 1) self.proxy_pass_lineEdit = QLineEdit(self.proxy_frame) self.proxy_pass_lineEdit.setEchoMode(QLineEdit.Password) proxy_gridLayout.addWidget(self.proxy_pass_lineEdit, 2, 3, 1, 1) self.ip_label = QLabel(self.proxy_frame) proxy_gridLayout.addWidget(self.ip_label, 0, 0, 1, 1) self.proxy_user_lineEdit = QLineEdit(self.proxy_frame) proxy_gridLayout.addWidget(self.proxy_user_lineEdit, 0, 3, 1, 1) self.proxy_user_label = QLabel(self.proxy_frame) proxy_gridLayout.addWidget(self.proxy_user_label, 0, 2, 1, 1) self.port_label = QLabel(self.proxy_frame) proxy_gridLayout.addWidget(self.port_label, 2, 0, 1, 1) self.port_spinBox = QSpinBox(self.proxy_frame) self.port_spinBox.setMaximum(9999) self.port_spinBox.setSingleStep(1) proxy_gridLayout.addWidget(self.port_spinBox, 2, 1, 1, 1) proxy_verticalLayout.addWidget(self.proxy_frame) options_tab_verticalLayout.addLayout(proxy_verticalLayout) # download UserName & Password download_horizontalLayout = QHBoxLayout() download_horizontalLayout.setContentsMargins(-1, 10, -1, -1) download_verticalLayout = QVBoxLayout() self.download_checkBox = QCheckBox(self.options_tab) download_verticalLayout.addWidget(self.download_checkBox) self.download_frame = QFrame(self.options_tab) self.download_frame.setFrameShape(QFrame.StyledPanel) self.download_frame.setFrameShadow(QFrame.Raised) download_gridLayout = QGridLayout(self.download_frame) self.download_user_lineEdit = QLineEdit(self.download_frame) download_gridLayout.addWidget(self.download_user_lineEdit, 0, 1, 1, 1) self.download_user_label = QLabel(self.download_frame) download_gridLayout.addWidget(self.download_user_label, 0, 0, 1, 1) self.download_pass_label = QLabel(self.download_frame) download_gridLayout.addWidget(self.download_pass_label, 1, 0, 1, 1) self.download_pass_lineEdit = QLineEdit(self.download_frame) self.download_pass_lineEdit.setEchoMode(QLineEdit.Password) download_gridLayout.addWidget(self.download_pass_lineEdit, 1, 1, 1, 1) download_verticalLayout.addWidget(self.download_frame) download_horizontalLayout.addLayout(download_verticalLayout) # select folder self.folder_frame = QFrame(self.options_tab) self.folder_frame.setFrameShape(QFrame.StyledPanel) self.folder_frame.setFrameShadow(QFrame.Raised) folder_gridLayout = QGridLayout(self.folder_frame) self.download_folder_lineEdit = QLineEdit(self.folder_frame) folder_gridLayout.addWidget(self.download_folder_lineEdit, 2, 0, 1, 1) self.folder_pushButton = QPushButton(self.folder_frame) folder_gridLayout.addWidget(self.folder_pushButton, 3, 0, 1, 1) self.folder_pushButton.setIcon(QIcon(icons + 'folder')) self.folder_label = QLabel(self.folder_frame) self.folder_label.setAlignment(QtCore.Qt.AlignCenter) folder_gridLayout.addWidget(self.folder_label, 1, 0, 1, 1) download_horizontalLayout.addWidget(self.folder_frame) options_tab_verticalLayout.addLayout(download_horizontalLayout) self.queue_tabWidget.addTab(self.options_tab, '') # limit Speed limit_verticalLayout = QVBoxLayout() self.limit_checkBox = QCheckBox(self.options_tab) limit_verticalLayout.addWidget(self.limit_checkBox) self.limit_frame = QFrame(self.options_tab) self.limit_frame.setFrameShape(QFrame.StyledPanel) self.limit_frame.setFrameShadow(QFrame.Raised) limit_horizontalLayout = QHBoxLayout(self.limit_frame) self.limit_spinBox = QSpinBox(self.limit_frame) self.limit_spinBox.setMinimum(1) self.limit_spinBox.setMaximum(1023) limit_horizontalLayout.addWidget(self.limit_spinBox) self.limit_comboBox = QComboBox(self.limit_frame) self.limit_comboBox.addItem("KiB/S") self.limit_comboBox.addItem("MiB/S") limit_horizontalLayout.addWidget(self.limit_comboBox) limit_verticalLayout.addWidget(self.limit_frame) limit_connections_horizontalLayout = QHBoxLayout() limit_connections_horizontalLayout.addLayout(limit_verticalLayout) # number of connections connections_horizontalLayout = QHBoxLayout() connections_horizontalLayout.setContentsMargins(-1, 10, -1, -1) self.connections_frame = QFrame(self.options_tab) self.connections_frame.setFrameShape(QFrame.StyledPanel) self.connections_frame.setFrameShadow(QFrame.Raised) horizontalLayout_3 = QHBoxLayout(self.connections_frame) self.connections_label = QLabel(self.connections_frame) horizontalLayout_3.addWidget(self.connections_label) self.connections_spinBox = QSpinBox(self.connections_frame) self.connections_spinBox.setMinimum(1) self.connections_spinBox.setMaximum(16) self.connections_spinBox.setProperty("value", 16) horizontalLayout_3.addWidget(self.connections_spinBox) connections_horizontalLayout.addWidget(self.connections_frame) limit_connections_horizontalLayout.addLayout(connections_horizontalLayout) options_tab_verticalLayout.addLayout(limit_connections_horizontalLayout) options_tab_verticalLayout.addStretch(1) # buttons buttons_horizontalLayout = QHBoxLayout() buttons_horizontalLayout.addStretch(1) # ok_pushButton self.ok_pushButton = QPushButton(self) self.ok_pushButton.setIcon(QIcon(icons + 'ok')) buttons_horizontalLayout.addWidget(self.ok_pushButton) # cancel_pushButton self.cancel_pushButton = QPushButton(self) self.cancel_pushButton.setIcon(QIcon(icons + 'remove')) buttons_horizontalLayout.addWidget(self.cancel_pushButton) window_verticalLayout.addLayout(buttons_horizontalLayout) # labels self.setWindowTitle(QCoreApplication.translate("text_ui_tr", "Persepolis Download Manager")) self.queue_tabWidget.setTabText( self.queue_tabWidget.indexOf(self.links_tab), QCoreApplication.translate("text_ui_tr", 'Links')) self.queue_tabWidget.setTabText( self.queue_tabWidget.indexOf(self.options_tab), QCoreApplication.translate("text_ui_tr", 'Download options')) self.select_all_pushButton.setText(QCoreApplication.translate("text_ui_tr", 'Select All')) self.deselect_all_pushButton.setText(QCoreApplication.translate("text_ui_tr", 'Deselect All')) self.add_queue_label.setText(QCoreApplication.translate("text_ui_tr", 'Add to queue: ')) self.proxy_checkBox.setText(QCoreApplication.translate("text_ui_tr", 'Proxy')) self.proxy_pass_label.setText(QCoreApplication.translate("text_ui_tr", "Proxy PassWord: "******"text_ui_tr", "IP:")) self.proxy_user_label.setText(QCoreApplication.translate("text_ui_tr", "Proxy UserName: "******"text_ui_tr", "Port:")) self.download_checkBox.setText(QCoreApplication.translate("text_ui_tr", "Download UserName and PassWord")) self.download_user_label.setText(QCoreApplication.translate("text_ui_tr", "Download UserName: "******"text_ui_tr", "Download PassWord: "******"text_ui_tr", "Change Download Folder")) self.folder_label.setText(QCoreApplication.translate("text_ui_tr", "Download Folder: ")) self.limit_checkBox.setText(QCoreApplication.translate("text_ui_tr", "Limit Speed")) self.connections_label.setText(QCoreApplication.translate("text_ui_tr", "Number Of Connections:")) self.ok_pushButton.setText(QCoreApplication.translate("text_ui_tr", 'OK')) self.cancel_pushButton.setText(QCoreApplication.translate("text_ui_tr", 'Cancel'))
def setUp(self): self.setUpQuamash() QLocale.setDefault(QLocale("en_GB")) ## Graph to test : ## ## A - B - C ## ## Path : Between A and C self.account_identity = Mock(specs='core.registry.Identity') self.account_identity.pubkey = "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk" self.account_identity.uid = "A" self.account_identity.is_member = CoroutineMock(spec='core.registry.Identity.is_member', return_value=True) self.idB = Mock(specs='core.registry.Identity') self.idB.pubkey = "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ" self.idB.uid = "B" self.idB.is_member = CoroutineMock(spec='core.registry.Identity.is_member', return_value=True) self.idC = Mock(specs='core.registry.Identity') self.idC.pubkey = "FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn" self.idC.uid = "C" self.idC.is_member = CoroutineMock(spec='core.registry.Identity.is_member', return_value=False) self.account_identity.unique_valid_certified_by = CoroutineMock(spec='core.registry.Identity.certified_by', return_value=[ { 'cert_time': 49800, 'identity': self.idB, 'block_number': 996 } ]) self.account_identity.unique_valid_certifiers_of = CoroutineMock(spec='core.registry.Identity.certifiers_of', return_value=[]) self.idC.unique_valid_certified_by = CoroutineMock(spec='core.registry.Identity.certifierd_by', return_value=[]) self.idC.unique_valid_certifiers_of = CoroutineMock(spec='core.registry.Identity.certifiers_of', return_value=[ { 'cert_time': 49100, 'identity': self.idB, 'block_number': 990 } ]) self.idB.unique_valid_certified_by = CoroutineMock(spec='core.registry.Identity.certified_by', return_value=[ { 'cert_time': 49100, 'identity': self.idC, 'block_number': 996 } ]) self.idB.unique_valid_certifiers_of = CoroutineMock(spec='core.registry.Identity.certifiers_of', return_value=[ { 'cert_time': 49800, 'identity': self.account_identity, 'block_number': 996 } ])
def everythingFinished(self): out = dict((x[0], x[1]) for x in self.networkResults.values()) for linia in self.getPESELfromUI(): self.ui.numeryPBN.appendPlainText(out[linia]) # ret) # self.ui.numeryPBN.setPlainText(outText) if __name__ == "__main__": import sys app = QApplication(sys.argv) QLocale.setDefault(QLocale("pl")) translator = QTranslator() if len(sys.argv) > 1: locale = sys.argv[1] else: locale = QLocale.system().name() translator.load('qt_%s' % locale, QLibraryInfo.location(QLibraryInfo.TranslationsPath)) app.installTranslator(translator) networkAccessManager = QNetworkAccessManager(app) window = Pesel2PBNWindow(networkAccessManager=networkAccessManager) window.show()
def setUp(self): QLocale.setDefault(QLocale("en_GB"))
def __init__(self, parent, persepolis_setting): super().__init__(persepolis_setting) self.persepolis_setting = persepolis_setting self.parent = parent self.grandparent = parent.persepolis_main self.persepolis_setting.beginGroup('settings') # initialization self.tries_spinBox.setValue( int(self.persepolis_setting.value('max-tries'))) self.wait_spinBox.setValue( int(self.persepolis_setting.value('retry-wait'))) self.time_out_spinBox.setValue( int(self.persepolis_setting.value('timeout'))) self.connections_spinBox.setValue( int(self.persepolis_setting.value('connections'))) self.rpc_port_spinbox.setValue( int(self.persepolis_setting.value('rpc-port'))) # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # wait_queue wait_queue_list = self.persepolis_setting.value('wait-queue') q_time = QTime(int(wait_queue_list[0]), int(wait_queue_list[1])) self.wait_queue_time.setTime(q_time) # change aria2 path self.aria2_path_pushButton.clicked.connect(self.changeAria2Path) self.aria2_path_checkBox.toggled.connect(self.ariaCheckBoxToggled) aria2_path = self.persepolis_setting.value('settings/aria2_path') self.aria2_path_lineEdit.setEnabled(False) if aria2_path != None: self.aria2_path_checkBox.setChecked(True) self.aria2_path_lineEdit.setText(str(aria2_path)) self.ariaCheckBoxToggled('aria2') if os_type == 'Linux' or os_type == 'FreeBSD' or os_type == 'OpenBSD': for widget in self.aria2_path_checkBox, self.aria2_path_lineEdit, self.aria2_path_pushButton: widget.hide() # save_as_tab self.download_folder_lineEdit.setText( str(self.persepolis_setting.value('download_path'))) self.temp_download_lineEdit.setText( str(self.persepolis_setting.value('download_path_temp'))) # subfolder if str(self.persepolis_setting.value('subfolder')) == 'yes': self.subfolder_checkBox.setChecked(True) else: self.subfolder_checkBox.setChecked(False) # notifications_tab self.volume_label.setText( 'Volume : ' + str(self.persepolis_setting.value('sound-volume'))) self.volume_dial.setValue( int(self.persepolis_setting.value('sound-volume'))) # set style # if style_comboBox is changed, self.styleComboBoxChanged is called. self.style_comboBox.currentIndexChanged.connect(self.styleComboBoxChanged) # find available styles(It's depends on operating system and desktop environments). available_styles = QStyleFactory.keys() for style in available_styles: # 'GTK' or 'gtk' styles may cause to crashing! Eliminate them! if 'gtk' not in str(style) and 'GTK' not in str(style): self.style_comboBox.addItem(style) # System >> for system default style # when user select System for style section, the default system style is using. self.style_comboBox.addItem('System') current_style_index = self.style_comboBox.findText( str(self.persepolis_setting.value('style'))) if current_style_index != -1: self.style_comboBox.setCurrentIndex(current_style_index) # available language available_language = ['en_US', 'fa_IR', 'zh_CN', 'fr_FR'] for lang in available_language: self.lang_comboBox.addItem(str(QLocale(lang).nativeLanguageName()), lang) current_locale = self.lang_comboBox.findData( str(self.persepolis_setting.value('locale'))) self.lang_comboBox.setCurrentIndex(current_locale) self.lang_comboBox.currentIndexChanged.connect(self.styleComboBoxChanged) self.styleComboBoxChanged() current_color_index = self.color_comboBox.findText( str(self.persepolis_setting.value('color-scheme'))) self.color_comboBox.setCurrentIndex(current_color_index) self.current_icon = self.persepolis_setting.value('icons') # icon size size = ['128', '64', '48', '32', '24', '16'] self.icons_size_comboBox.addItems(size) current_icons_size_index = self.icons_size_comboBox.findText( str(self.persepolis_setting.value('toolbar_icon_size'))) self.icons_size_comboBox.setCurrentIndex(current_icons_size_index) # call iconSizeComboBoxCanged if index is changed self.icons_size_comboBox.currentIndexChanged.connect(self.iconSizeComboBoxCanged) self.iconSizeComboBoxCanged(1) # set notification notifications = ['Native notification', 'QT notification'] self.notification_comboBox.addItems(notifications) current_notification_index = self.notification_comboBox.findText( str(self.persepolis_setting.value('notification'))) self.notification_comboBox.setCurrentIndex(current_notification_index) # set font font_setting = QFont() font_setting.setFamily(str(self.persepolis_setting.value('font'))) self.fontComboBox.setCurrentFont(font_setting) self.font_size_spinBox.setValue( int(self.persepolis_setting.value('font-size'))) # sound frame self.sound_frame.setEnabled(False) self.enable_notifications_checkBox.toggled.connect(self.soundFrame) if str(self.persepolis_setting.value('sound')) == 'yes': self.enable_notifications_checkBox.setChecked(True) else: self.enable_notifications_checkBox.setChecked(False) # connect folder buttons self.download_folder_lineEdit.setEnabled(False) self.download_folder_pushButton.clicked.connect( self.downloadFolderPushButtonClicked) self.temp_download_lineEdit.setEnabled(False) self.temp_download_pushButton.clicked.connect( self.tempDownloadPushButtonClicked) # dial self.volume_dial.setNotchesVisible(True) self.volume_dial.valueChanged.connect(self.dialChanged) # tray icon if str(self.persepolis_setting.value('tray-icon')) == 'yes': self.enable_system_tray_checkBox.setChecked(True) else: self.enable_notifications_checkBox.setChecked(False) # show_menubar if str(self.persepolis_setting.value('show-menubar')) == 'yes': self.show_menubar_checkbox.setChecked(True) else: self.show_menubar_checkbox.setChecked(False) if platform.system() == 'Darwin': self.show_menubar_checkbox.setChecked(True) self.show_menubar_checkbox.hide() # show_sidepanel if str(self.persepolis_setting.value('show-sidepanel')) == 'yes': self.show_sidepanel_checkbox.setChecked(True) else: self.show_sidepanel_checkbox.setChecked(False) # show ProgressWindow if str(self.persepolis_setting.value('show-progress')) == 'yes': self.show_progress_window_checkbox.setChecked(True) else: self.show_progress_window_checkbox.setChecked(False) # after download dialog if str(self.persepolis_setting.value('after-dialog')) == 'yes': self.after_download_checkBox.setChecked(True) else: self.after_download_checkBox.setChecked(False) # run persepolis at startup checkBox if str(self.persepolis_setting.value('startup')) == 'yes': self.startup_checkbox.setChecked(True) else: self.startup_checkbox.setChecked(False) # font_checkBox if str(self.persepolis_setting.value('custom-font')) == 'yes': self.font_checkBox.setChecked(True) else: self.font_checkBox.setChecked(False) self.fontCheckBoxState(self.font_checkBox) # keep_awake_checkBox if str(self.persepolis_setting.value('awake')) == 'yes': self.keep_awake_checkBox.setChecked(True) else: self.keep_awake_checkBox.setChecked(False) # columns_tab if str(self.persepolis_setting.value('column0')) == 'yes': self.column0_checkBox.setChecked(True) else: self.column0_checkBox.setChecked(False) if str(self.persepolis_setting.value('column1')) == 'yes': self.column1_checkBox.setChecked(True) else: self.column1_checkBox.setChecked(False) if str(self.persepolis_setting.value('column2')) == 'yes': self.column2_checkBox.setChecked(True) else: self.column2_checkBox.setChecked(False) if str(self.persepolis_setting.value('column3')) == 'yes': self.column3_checkBox.setChecked(True) else: self.column3_checkBox.setChecked(False) if str(self.persepolis_setting.value('column4')) == 'yes': self.column4_checkBox.setChecked(True) else: self.column4_checkBox.setChecked(False) if str(self.persepolis_setting.value('column5')) == 'yes': self.column5_checkBox.setChecked(True) else: self.column5_checkBox.setChecked(False) if str(self.persepolis_setting.value('column6')) == 'yes': self.column6_checkBox.setChecked(True) else: self.column6_checkBox.setChecked(False) if str(self.persepolis_setting.value('column7')) == 'yes': self.column7_checkBox.setChecked(True) else: self.column7_checkBox.setChecked(False) if str(self.persepolis_setting.value('column10')) == 'yes': self.column10_checkBox.setChecked(True) else: self.column10_checkBox.setChecked(False) if str(self.persepolis_setting.value('column11')) == 'yes': self.column11_checkBox.setChecked(True) else: self.column11_checkBox.setChecked(False) if str(self.persepolis_setting.value('column12')) == 'yes': self.column12_checkBox.setChecked(True) else: self.column12_checkBox.setChecked(False) # video_finder self.enable_video_finder_checkbox.stateChanged.connect(self.videoFinderFram) self.enable_video_finder_checkbox.setChecked(persepolis_setting.value('video_finder/enable', 'yes') == 'yes') self.hide_no_audio_checkbox.setChecked(persepolis_setting.value('video_finder/hide_no_audio') == 'yes') self.hide_no_video_checkbox.setChecked(persepolis_setting.value('video_finder/hide_no_video') == 'yes') try: # Integer casting may raise exception. self.max_links_spinBox.setValue(int(persepolis_setting.value('video_finder/max_links', 3))) except: pass self.videoFinderFram() # ok cancel default button self.cancel_pushButton.clicked.connect(self.close) self.defaults_pushButton.clicked.connect( self.defaultsPushButtonPressed) self.ok_pushButton.clicked.connect(self.okPushButtonPressed) # font_checkBox connect self.font_checkBox.stateChanged.connect(self.fontCheckBoxState) # saving initial value of self.persepolis_setting in self.first_key_value_dict # at the end! in the okPushButtonPressed method, first_key_value_dict will compared with second_key_value_dict. # if any thing changed , then a message box notify user about "some changes take effect after restarting persepolis". self.first_key_value_dict = {} for member in self.persepolis_setting.allKeys(): self.first_key_value_dict[member] = str(self.persepolis_setting.value(member)) self.persepolis_setting.endGroup() # setting window size and position size = self.persepolis_setting.value( 'PreferencesWindow/size', QSize(578, 565)) position = self.persepolis_setting.value( 'PreferencesWindow/position', QPoint(300, 300)) self.resize(size) self.move(position)
def __init__(self, persepolis_setting): super().__init__() # MainWindow self.persepolis_setting = persepolis_setting # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) icons = ':/' + \ str(self.persepolis_setting.value('settings/icons')) + '/' self.setWindowTitle(QCoreApplication.translate("mainwindow_ui_tr", "Persepolis Download Manager")) self.setWindowIcon(QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) self.centralwidget = QWidget(self) self.verticalLayout = QVBoxLayout(self.centralwidget) # enable drag and drop self.setAcceptDrops(True) # frame self.frame = QFrame(self.centralwidget) # download_table_horizontalLayout download_table_horizontalLayout = QHBoxLayout() tabels_splitter = QSplitter(Qt.Horizontal) # category_tree self.category_tree_qwidget = QWidget(self) category_tree_verticalLayout = QVBoxLayout() self.category_tree = CategoryTreeView(self) category_tree_verticalLayout.addWidget(self.category_tree) self.category_tree_model = QStandardItemModel() self.category_tree.setModel(self.category_tree_model) category_table_header = [QCoreApplication.translate("mainwindow_ui_tr", 'Category')] self.category_tree_model.setHorizontalHeaderLabels( category_table_header) self.category_tree.header().setStretchLastSection(True) self.category_tree.header().setDefaultAlignment(Qt.AlignCenter) # queue_panel self.queue_panel_widget = QWidget(self) queue_panel_verticalLayout_main = QVBoxLayout(self.queue_panel_widget) # queue_panel_show_button self.queue_panel_show_button = QPushButton(self) queue_panel_verticalLayout_main.addWidget(self.queue_panel_show_button) # queue_panel_widget_frame self.queue_panel_widget_frame = QFrame(self) self.queue_panel_widget_frame.setFrameShape(QFrame.StyledPanel) self.queue_panel_widget_frame.setFrameShadow(QFrame.Raised) queue_panel_verticalLayout_main.addWidget( self.queue_panel_widget_frame) queue_panel_verticalLayout = QVBoxLayout(self.queue_panel_widget_frame) queue_panel_verticalLayout_main.setContentsMargins(50, -1, 50, -1) # start_end_frame self.start_end_frame = QFrame(self) # start time start_verticalLayout = QVBoxLayout(self.start_end_frame) self.start_checkBox = QCheckBox(self) start_verticalLayout.addWidget(self.start_checkBox) self.start_frame = QFrame(self) self.start_frame.setFrameShape(QFrame.StyledPanel) self.start_frame.setFrameShadow(QFrame.Raised) start_frame_verticalLayout = QVBoxLayout(self.start_frame) self.start_time_qDataTimeEdit = QDateTimeEdit(self.start_frame) self.start_time_qDataTimeEdit.setDisplayFormat('H:mm') start_frame_verticalLayout.addWidget(self.start_time_qDataTimeEdit) start_verticalLayout.addWidget(self.start_frame) # end time self.end_checkBox = QCheckBox(self) start_verticalLayout.addWidget(self.end_checkBox) self.end_frame = QFrame(self) self.end_frame.setFrameShape(QFrame.StyledPanel) self.end_frame.setFrameShadow(QFrame.Raised) end_frame_verticalLayout = QVBoxLayout(self.end_frame) self.end_time_qDateTimeEdit = QDateTimeEdit(self.end_frame) self.end_time_qDateTimeEdit.setDisplayFormat('H:mm') end_frame_verticalLayout.addWidget(self.end_time_qDateTimeEdit) start_verticalLayout.addWidget(self.end_frame) self.reverse_checkBox = QCheckBox(self) start_verticalLayout.addWidget(self.reverse_checkBox) queue_panel_verticalLayout.addWidget(self.start_end_frame) # limit_after_frame self.limit_after_frame = QFrame(self) # limit_checkBox limit_verticalLayout = QVBoxLayout(self.limit_after_frame) self.limit_checkBox = QCheckBox(self) limit_verticalLayout.addWidget(self.limit_checkBox) # limit_frame self.limit_frame = QFrame(self) self.limit_frame.setFrameShape(QFrame.StyledPanel) self.limit_frame.setFrameShadow(QFrame.Raised) limit_verticalLayout.addWidget(self.limit_frame) limit_frame_verticalLayout = QVBoxLayout(self.limit_frame) # limit_spinBox limit_frame_horizontalLayout = QHBoxLayout() self.limit_spinBox = QDoubleSpinBox(self) self.limit_spinBox.setMinimum(1) self.limit_spinBox.setMaximum(1023) limit_frame_horizontalLayout.addWidget(self.limit_spinBox) # limit_comboBox self.limit_comboBox = QComboBox(self) self.limit_comboBox.addItem("") self.limit_comboBox.addItem("") limit_frame_horizontalLayout.addWidget(self.limit_comboBox) limit_frame_verticalLayout.addLayout(limit_frame_horizontalLayout) # limit_pushButton self.limit_pushButton = QPushButton(self) limit_frame_verticalLayout.addWidget(self.limit_pushButton) # after_checkBox self.after_checkBox = QtWidgets.QCheckBox(self) limit_verticalLayout.addWidget(self.after_checkBox) # after_frame self.after_frame = QtWidgets.QFrame(self) self.after_frame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.after_frame.setFrameShadow(QtWidgets.QFrame.Raised) limit_verticalLayout.addWidget(self.after_frame) after_frame_verticalLayout = QVBoxLayout(self.after_frame) # after_comboBox self.after_comboBox = QComboBox(self) self.after_comboBox.addItem("") after_frame_verticalLayout.addWidget(self.after_comboBox) # after_pushButton self.after_pushButton = QPushButton(self) after_frame_verticalLayout.addWidget(self.after_pushButton) queue_panel_verticalLayout.addWidget(self.limit_after_frame) category_tree_verticalLayout.addWidget(self.queue_panel_widget) # keep_awake_checkBox self.keep_awake_checkBox = QCheckBox(self) queue_panel_verticalLayout.addWidget(self.keep_awake_checkBox) self.category_tree_qwidget.setLayout(category_tree_verticalLayout) tabels_splitter.addWidget(self.category_tree_qwidget) # download table widget self.download_table_content_widget = QWidget(self) download_table_content_widget_verticalLayout = QVBoxLayout( self.download_table_content_widget) self.download_table = DownloadTableWidget(self) download_table_content_widget_verticalLayout.addWidget( self.download_table) tabels_splitter.addWidget(self.download_table_content_widget) self.download_table.setColumnCount(13) self.download_table.setSelectionBehavior(QAbstractItemView.SelectRows) self.download_table.setEditTriggers(QAbstractItemView.NoEditTriggers) self.download_table.verticalHeader().hide() # hide gid and download dictioanry section self.download_table.setColumnHidden(8, True) self.download_table.setColumnHidden(9, True) download_table_header = [QCoreApplication.translate("mainwindow_ui_tr", 'File Name'), QCoreApplication.translate("mainwindow_ui_tr",'Status'), QCoreApplication.translate("mainwindow_ui_tr", 'Size'), QCoreApplication.translate("mainwindow_ui_tr", 'Downloaded'), QCoreApplication.translate("mainwindow_ui_tr", 'Percentage'), QCoreApplication.translate("mainwindow_ui_tr", 'Connections'), QCoreApplication.translate("mainwindow_ui_tr", 'Transfer rate'), QCoreApplication.translate("mainwindow_ui_tr",'Estimated time left'), 'Gid', QCoreApplication.translate("mainwindow_ui_tr",'Link'), QCoreApplication.translate("mainwindow_ui_tr", 'First try date'), QCoreApplication.translate("mainwindow_ui_tr", 'Last try date'), QCoreApplication.translate("mainwindow_ui_tr",'Category')] self.download_table.setHorizontalHeaderLabels(download_table_header) # fixing the size of download_table when window is Maximized! self.download_table.horizontalHeader().setSectionResizeMode(0) self.download_table.horizontalHeader().setStretchLastSection(True) tabels_splitter.setStretchFactor(0, 3) # category_tree width tabels_splitter.setStretchFactor(1, 10) # ratio of tables's width download_table_horizontalLayout.addWidget(tabels_splitter) self.frame.setLayout(download_table_horizontalLayout) self.verticalLayout.addWidget(self.frame) self.setCentralWidget(self.centralwidget) # menubar self.menubar = QMenuBar(self) self.menubar.setGeometry(QRect(0, 0, 600, 24)) self.setMenuBar(self.menubar) fileMenu = self.menubar.addMenu(QCoreApplication.translate("mainwindow_ui_tr", '&File')) editMenu = self.menubar.addMenu(QCoreApplication.translate("mainwindow_ui_tr", '&Edit')) viewMenu = self.menubar.addMenu(QCoreApplication.translate("mainwindow_ui_tr", '&View')) downloadMenu = self.menubar.addMenu(QCoreApplication.translate("mainwindow_ui_tr", '&Download')) queueMenu = self.menubar.addMenu(QCoreApplication.translate("mainwindow_ui_tr", '&Queue')) videoFinderMenu = self.menubar.addMenu(QCoreApplication.translate("mainwindow_ui_tr", 'V&ideo Finder')) helpMenu = self.menubar.addMenu(QCoreApplication.translate("mainwindow_ui_tr", '&Help')) # viewMenu submenus sortMenu = viewMenu.addMenu(QCoreApplication.translate("mainwindow_ui_tr", 'Sort by')) # statusbar self.statusbar = QStatusBar(self) self.setStatusBar(self.statusbar) self.statusbar.showMessage(QCoreApplication.translate("mainwindow_ui_tr", "Persepolis Download Manager")) # toolBar self.toolBar2 = QToolBar(self) self.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar2) self.toolBar2.setWindowTitle(QCoreApplication.translate("mainwindow_ui_tr", 'Menu')) self.toolBar2.setFloatable(False) self.toolBar2.setMovable(False) self.toolBar = QToolBar(self) self.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar) self.toolBar.setWindowTitle(QCoreApplication.translate("mainwindow_ui_tr", 'Toolbar')) self.toolBar.setFloatable(False) self.toolBar.setMovable(False) #toolBar and menubar and actions self.videoFinderAddLinkAction = QAction(QIcon(icons + 'video_finder'), QCoreApplication.translate("mainwindow_ui_tr", 'Find Video Links'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Download video or audio from Youtube, Vimeo, etc...'), triggered=self.showVideoFinderAddLinkWindow) QShortcut(QKeySequence('Ctrl+I'), self, self.showVideoFinderAddLinkWindow) videoFinderMenu.addAction(self.videoFinderAddLinkAction) self.stopAllAction = QAction(QIcon(icons + 'stop_all'), QCoreApplication.translate("mainwindow_ui_tr", 'Stop all active downloads'), self, statusTip='Stop all active downloads', triggered=self.stopAllDownloads) downloadMenu.addAction(self.stopAllAction) self.sort_file_name_Action = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'File name'), self, triggered=self.sortByName) sortMenu.addAction(self.sort_file_name_Action) self.sort_file_size_Action = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'File size'), self, triggered=self.sortBySize) sortMenu.addAction(self.sort_file_size_Action) self.sort_first_try_date_Action = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'First try date'), self, triggered=self.sortByFirstTry) sortMenu.addAction(self.sort_first_try_date_Action) self.sort_last_try_date_Action = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'Last try date'), self, triggered=self.sortByLastTry) sortMenu.addAction(self.sort_last_try_date_Action) self.sort_download_status_Action = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'Download status'), self, triggered=self.sortByStatus) sortMenu.addAction(self.sort_download_status_Action) self.trayAction = QAction(QCoreApplication.translate("mainwindow_ui_tr", 'Show system tray icon'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Show/Hide system tray icon"), triggered=self.showTray) self.trayAction.setCheckable(True) viewMenu.addAction(self.trayAction) self.showMenuBarAction = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'Show menubar'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Show menubar'), triggered=self.showMenuBar) self.showMenuBarAction.setCheckable(True) viewMenu.addAction(self.showMenuBarAction) self.showSidePanelAction = QAction( QCoreApplication.translate("mainwindow_ui_tr", 'Show side panel'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Show side panel'), triggered=self.showSidePanel) self.showSidePanelAction.setCheckable(True) viewMenu.addAction(self.showSidePanelAction) self.minimizeAction = QAction(QIcon(icons + 'minimize'), QCoreApplication.translate("mainwindow_ui_tr", 'Minimize to system tray'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Minimize to system tray"), triggered=self.minMaxTray) QShortcut(QKeySequence('Ctrl+W'), self, self.minMaxTray) viewMenu.addAction(self.minimizeAction) self.addlinkAction = QAction(QIcon(icons + 'add'), QCoreApplication.translate("mainwindow_ui_tr", 'Add New Download Link'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Add New Download Link"), triggered=self.addLinkButtonPressed) QShortcut(QKeySequence('Ctrl+N'), self, self.addLinkButtonPressed) fileMenu.addAction(self.addlinkAction) self.addtextfileAction = QAction(QIcon(icons + 'file'), QCoreApplication.translate("mainwindow_ui_tr", 'Import links from text file'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Create a Text file and put links in it.line by line!'), triggered=self.importText) fileMenu.addAction(self.addtextfileAction) self.resumeAction = QAction(QIcon(icons + 'play'), QCoreApplication.translate("mainwindow_ui_tr", 'Resume Download'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Resume Download"), triggered=self.resumeButtonPressed) QShortcut(QKeySequence('Ctrl+R'), self, self.resumeButtonPressed) downloadMenu.addAction(self.resumeAction) self.pauseAction = QAction(QIcon(icons + 'pause'), QCoreApplication.translate("mainwindow_ui_tr", 'Pause Download'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Pause Download"), triggered=self.pauseButtonPressed) QShortcut(QKeySequence('Ctrl+C'), self, self.pauseButtonPressed) downloadMenu.addAction(self.pauseAction) self.stopAction = QAction(QIcon(icons + 'stop'), QCoreApplication.translate("mainwindow_ui_tr", 'Stop Download'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Stop/Cancel Download"), triggered=self.stopButtonPressed) QShortcut(QKeySequence('Ctrl+S'), self, self.stopButtonPressed) downloadMenu.addAction(self.stopAction) self.propertiesAction = QAction(QIcon(icons + 'setting'), QCoreApplication.translate("mainwindow_ui_tr", 'Properties'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Properties"), triggered=self.propertiesButtonPressed) QShortcut(QKeySequence('Ctrl+P'), self, self.propertiesButtonPressed) downloadMenu.addAction(self.propertiesAction) self.progressAction = QAction(QIcon(icons + 'window'), QCoreApplication.translate("mainwindow_ui_tr", 'Progress'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Progress"), triggered=self.progressButtonPressed) QShortcut(QKeySequence('Ctrl+Z'), self, self.progressButtonPressed) downloadMenu.addAction(self.progressAction) self.openFileAction = QAction(QIcon( icons + 'file'), QCoreApplication.translate("mainwindow_ui_tr", 'Open file'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Open file'), triggered=self.openFile) fileMenu.addAction(self.openFileAction) self.openDownloadFolderAction = QAction(QIcon( icons + 'folder'), QCoreApplication.translate("mainwindow_ui_tr", 'Open download folder'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Open download folder'), triggered=self.openDownloadFolder) fileMenu.addAction(self.openDownloadFolderAction) self.openDefaultDownloadFolderAction = QAction(QIcon( icons + 'folder'), QCoreApplication.translate("mainwindow_ui_tr", 'Open default download folder'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Open default download folder'), triggered=self.openDefaultDownloadFolder) fileMenu.addAction(self.openDefaultDownloadFolderAction) self.exitAction = QAction(QIcon(icons + 'exit'), QCoreApplication.translate("mainwindow_ui_tr", 'Exit'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", "Exit"), triggered=self.closeEvent) QShortcut(QKeySequence('Ctrl+Q'), self, self.closeEvent) fileMenu.addAction(self.exitAction) self.clearAction = QAction(QIcon(icons + 'multi_remove'), QCoreApplication.translate("mainwindow_ui_tr", 'Clear download list'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Clear all items in download list'), triggered=self.clearDownloadList) editMenu.addAction(self.clearAction) self.removeSelectedAction = QAction(QIcon(icons + 'remove'), QCoreApplication.translate("mainwindow_ui_tr", 'Remove selected downloads from list'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Remove selected downloads form list'), triggered=self.removeSelected) editMenu.addAction(self.removeSelectedAction) self.removeSelectedAction.setEnabled(False) self.deleteSelectedAction = QAction(QIcon(icons + 'trash'), QCoreApplication.translate("mainwindow_ui_tr", 'Delete selected download files'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Delete selected download files'), triggered=self.deleteSelected) editMenu.addAction(self.deleteSelectedAction) self.deleteSelectedAction.setEnabled(False) self.createQueueAction = QAction(QIcon(icons + 'add_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Create new queue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Create new download queue'), triggered=self.createQueue) queueMenu.addAction(self.createQueueAction) self.removeQueueAction = QAction(QIcon(icons + 'remove_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Remove this queue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Remove this queue'), triggered=self.removeQueue) queueMenu.addAction(self.removeQueueAction) self.startQueueAction = QAction(QIcon( icons + 'start_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Start this queue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Start this queue'), triggered=self.startQueue) queueMenu.addAction(self.startQueueAction) self.stopQueueAction = QAction(QIcon( icons + 'stop_queue'), QCoreApplication.translate("mainwindow_ui_tr", 'Stop this queue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Stop this queue'), triggered=self.stopQueue) queueMenu.addAction(self.stopQueueAction) self.moveUpSelectedAction = QAction(QIcon(icons + 'multi_up'), QCoreApplication.translate("mainwindow_ui_tr", 'Move up selected items'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Move currently selected items up by one row'), triggered=self.moveUpSelected) queueMenu.addAction(self.moveUpSelectedAction) self.moveDownSelectedAction = QAction(QIcon(icons + 'multi_down'), QCoreApplication.translate("mainwindow_ui_tr", 'Move down selected items'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Move currently selected items down by one row'), triggered=self.moveDownSelected) queueMenu.addAction(self.moveDownSelectedAction) self.preferencesAction = QAction(QIcon(icons + 'preferences'), QCoreApplication.translate("mainwindow_ui_tr", 'Preferences'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Preferences'), triggered=self.openPreferences, menuRole=5) editMenu.addAction(self.preferencesAction) self.aboutAction = QAction(QIcon( icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'About'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'About'), triggered=self.openAbout, menuRole=4) helpMenu.addAction(self.aboutAction) self.issueAction = QAction(QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Report an issue'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Report an issue'), triggered=self.reportIssue) helpMenu.addAction(self.issueAction) self.updateAction = QAction(QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Check for newer version'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Check for newer release'), triggered=self.newUpdate) helpMenu.addAction(self.updateAction) self.logAction = QAction(QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Show log file'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Help'), triggered=self.showLog) helpMenu.addAction(self.logAction) self.helpAction = QAction(QIcon(icons + 'about'), QCoreApplication.translate("mainwindow_ui_tr", 'Help'), self, statusTip=QCoreApplication.translate("mainwindow_ui_tr", 'Help'), triggered=self.persepolisHelp) helpMenu.addAction(self.helpAction) self.qmenu = MenuWidget(self) self.toolBar2.addWidget(self.qmenu) # labels self.queue_panel_show_button.setText(QCoreApplication.translate("mainwindow_ui_tr", "Hide options")) self.start_checkBox.setText(QCoreApplication.translate("mainwindow_ui_tr", "Start Time")) self.end_checkBox.setText(QCoreApplication.translate("mainwindow_ui_tr", "End Time")) self.reverse_checkBox.setText(QCoreApplication.translate("mainwindow_ui_tr", "Download bottom of\n the list first")) self.limit_checkBox.setText(QCoreApplication.translate("mainwindow_ui_tr", "Limit Speed")) self.limit_comboBox.setItemText(0, "KiB/s") self.limit_comboBox.setItemText(1, "MiB/s") self.limit_pushButton.setText(QCoreApplication.translate("mainwindow_ui_tr", "Apply")) self.after_checkBox.setText(QCoreApplication.translate("mainwindow_ui_tr", "After download")) self.after_comboBox.setItemText(0, QCoreApplication.translate("mainwindow_ui_tr", "Shut Down")) self.keep_awake_checkBox.setText(QCoreApplication.translate("mainwindow_ui_tr", "Keep system awake!")) self.keep_awake_checkBox.setToolTip( QCoreApplication.translate("mainwindow_ui_tr", "<html><head/><body><p>This option is preventing system from going to sleep.\ This is necessary if your power manager is suspending system automatically. </p></body></html>")) self.after_pushButton.setText(QCoreApplication.translate("mainwindow_ui_tr", "Apply"))
def __init__(self, parent): super().__init__() self.parent = parent icons = ':/' + \ str(self.parent.persepolis_setting.value('settings/icons')) + '/' # add support for other languages locale = str(self.parent.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # set ui direction ui_direction = self.parent.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) # creating context menu self.menubar = QMenu(self) self.setMenu(self.menubar) self.setIcon(QIcon(icons + 'menu')) fileMenu = self.menubar.addMenu(QCoreApplication.translate("mainwindow_ui_tr", 'File')) editMenu = self.menubar.addMenu(QCoreApplication.translate("mainwindow_ui_tr", 'Edit')) viewMenu = self.menubar.addMenu(QCoreApplication.translate("mainwindow_ui_tr", 'View')) downloadMenu = self.menubar.addMenu(QCoreApplication.translate("mainwindow_ui_tr", 'Download')) queueMenu = self.menubar.addMenu(QCoreApplication.translate("mainwindow_ui_tr", 'Queue')) videoFinderMenu = self.menubar.addMenu(QCoreApplication.translate("mainwindow_ui_tr", 'Video Finder')) helpMenu = self.menubar.addMenu(QCoreApplication.translate("mainwindow_ui_tr", 'Help')) sortMenu = viewMenu.addMenu(QCoreApplication.translate("mainwindow_ui_tr", 'Sort by')) videoFinderMenu.addAction(self.parent.videoFinderAddLinkAction) downloadMenu.addAction(self.parent.stopAllAction) sortMenu.addAction(self.parent.sort_file_name_Action) sortMenu.addAction(self.parent.sort_file_size_Action) sortMenu.addAction(self.parent.sort_first_try_date_Action) sortMenu.addAction(self.parent.sort_last_try_date_Action) sortMenu.addAction(self.parent.sort_download_status_Action) viewMenu.addAction(self.parent.trayAction) viewMenu.addAction(self.parent.showMenuBarAction) viewMenu.addAction(self.parent.showSidePanelAction) viewMenu.addAction(self.parent.minimizeAction) fileMenu.addAction(self.parent.addlinkAction) fileMenu.addAction(self.parent.addtextfileAction) downloadMenu.addAction(self.parent.resumeAction) downloadMenu.addAction(self.parent.pauseAction) downloadMenu.addAction(self.parent.stopAction) downloadMenu.addAction(self.parent.propertiesAction) downloadMenu.addAction(self.parent.progressAction) fileMenu.addAction(self.parent.openFileAction) fileMenu.addAction(self.parent.openDownloadFolderAction) fileMenu.addAction(self.parent.openDefaultDownloadFolderAction) fileMenu.addAction(self.parent.exitAction) editMenu.addAction(self.parent.clearAction) editMenu.addAction(self.parent.removeSelectedAction) editMenu.addAction(self.parent.deleteSelectedAction) queueMenu.addAction(self.parent.createQueueAction) queueMenu.addAction(self.parent.removeQueueAction) queueMenu.addAction(self.parent.startQueueAction) queueMenu.addAction(self.parent.stopQueueAction) queueMenu.addAction(self.parent.moveUpSelectedAction) queueMenu.addAction(self.parent.moveDownSelectedAction) editMenu.addAction(self.parent.preferencesAction) helpMenu.addAction(self.parent.aboutAction) helpMenu.addAction(self.parent.issueAction) helpMenu.addAction(self.parent.updateAction) helpMenu.addAction(self.parent.logAction) helpMenu.addAction(self.parent.helpAction)
def __init__(self,persepolis_setting): super().__init__() self.persepolis_setting = persepolis_setting # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) icons = ':/' + \ str(self.persepolis_setting.value('settings/icons')) + '/' self.setMinimumSize(QSize(545, 375)) self.setWindowIcon(QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) verticalLayout = QVBoxLayout(self) self.about_tabWidget = QTabWidget(self) # about tab self.about_tab = QWidget(self) about_tab_horizontalLayout = QHBoxLayout(self.about_tab) about_tab_verticalLayout = QVBoxLayout() # persepolis icon if qtsvg_available: persepolis_icon_verticalLayout = QVBoxLayout() self.persepolis_icon = QtSvg.QSvgWidget(':/persepolis.svg') self.persepolis_icon.setFixedSize(QSize(64, 64)) persepolis_icon_verticalLayout.addWidget(self.persepolis_icon) persepolis_icon_verticalLayout.addStretch(1) about_tab_horizontalLayout.addLayout(persepolis_icon_verticalLayout) self.title_label = QLabel(self.about_tab) font = QFont() font.setBold(True) font.setWeight(75) self.title_label.setFont(font) self.title_label.setAlignment(Qt.AlignCenter) about_tab_verticalLayout.addWidget(self.title_label) self.version_label = QLabel(self.about_tab) self.version_label.setAlignment(Qt.AlignCenter) about_tab_verticalLayout.addWidget(self.version_label) self.site2_label = QLabel(self.about_tab) self.site2_label.setTextFormat(Qt.RichText) self.site2_label.setAlignment(Qt.AlignCenter) self.site2_label.setOpenExternalLinks(True) self.site2_label.setTextInteractionFlags( Qt.TextBrowserInteraction) about_tab_verticalLayout.addWidget(self.site2_label) self.telegram_label = QLabel(self.about_tab) self.telegram_label.setTextFormat(Qt.RichText) self.telegram_label.setAlignment(Qt.AlignCenter) self.telegram_label.setOpenExternalLinks(True) self.telegram_label.setTextInteractionFlags( Qt.TextBrowserInteraction) about_tab_verticalLayout.addWidget(self.telegram_label) self.twitter_label = QLabel(self.about_tab) self.twitter_label.setTextFormat(Qt.RichText) self.twitter_label.setAlignment(Qt.AlignCenter) self.twitter_label.setOpenExternalLinks(True) self.twitter_label.setTextInteractionFlags( Qt.TextBrowserInteraction) about_tab_verticalLayout.addWidget(self.twitter_label) about_tab_verticalLayout.addStretch(1) about_tab_horizontalLayout.addLayout(about_tab_verticalLayout) # developers_tab # developers self.developers_tab = QWidget(self) developers_verticalLayout = QVBoxLayout(self.developers_tab) self.developers_title_label = QLabel(self.developers_tab) font.setBold(True) font.setWeight(75) self.developers_title_label.setFont(font) self.developers_title_label.setAlignment(Qt.AlignCenter) developers_verticalLayout.addWidget(self.developers_title_label) self.name_label = QLabel(self.developers_tab) self.name_label.setAlignment(Qt.AlignCenter) developers_verticalLayout.addWidget(self.name_label) # contributors self.contributors_thank_label = QLabel(self.developers_tab) self.contributors_thank_label.setFont(font) self.contributors_thank_label.setAlignment(Qt.AlignCenter) developers_verticalLayout.addWidget(self.contributors_thank_label) self.contributors_link_label = QLabel(self.developers_tab) self.contributors_link_label.setTextFormat(Qt.RichText) self.contributors_link_label.setAlignment(Qt.AlignCenter) self.contributors_link_label.setOpenExternalLinks(True) self.contributors_link_label.setTextInteractionFlags( Qt.TextBrowserInteraction) developers_verticalLayout.addWidget(self.contributors_link_label) developers_verticalLayout.addStretch(1) # translators tab self.translators_tab = QWidget(self) translators_tab_verticalLayout = QVBoxLayout(self.translators_tab) # chinese translators self.chinese_translators_label = QLabel(self.translators_tab) self.chinese_translators_label.setFont(font) self.chinese_translators_label.setAlignment(Qt.AlignCenter) translators_tab_verticalLayout.addWidget(self.chinese_translators_label) self.chinese_translatos_name_label = QLabel(self.translators_tab) self.chinese_translatos_name_label.setAlignment(Qt.AlignCenter) translators_tab_verticalLayout.addWidget(self.chinese_translatos_name_label) # french translators self.french_translators_label = QLabel(self.translators_tab) self.french_translators_label.setFont(font) self.french_translators_label.setAlignment(Qt.AlignCenter) translators_tab_verticalLayout.addWidget(self.french_translators_label) self.french_translatos_name_label = QLabel(self.translators_tab) self.french_translatos_name_label.setAlignment(Qt.AlignCenter) translators_tab_verticalLayout.addWidget(self.french_translatos_name_label) # persian translators self.persian_translators_label = QLabel(self.translators_tab) self.persian_translators_label.setFont(font) self.persian_translators_label.setAlignment(Qt.AlignCenter) translators_tab_verticalLayout.addWidget(self.persian_translators_label) self.persian_translatos_name_label = QLabel(self.translators_tab) self.persian_translatos_name_label.setAlignment(Qt.AlignCenter) translators_tab_verticalLayout.addWidget(self.persian_translatos_name_label) translators_tab_verticalLayout.addStretch(1) # License tab self.license_tab = QWidget(self) license_tab_verticalLayout = QVBoxLayout(self.license_tab) self.license_text = QTextEdit(self.license_tab) self.license_text.setReadOnly(True) license_tab_verticalLayout.addWidget(self.license_text) verticalLayout.addWidget(self.about_tabWidget) # buttons button_horizontalLayout = QHBoxLayout() button_horizontalLayout.addStretch(1) self.pushButton = QPushButton(self) self.pushButton.setIcon(QIcon(icons + 'ok')) self.pushButton.clicked.connect(self.close) button_horizontalLayout.addWidget(self.pushButton) verticalLayout.addLayout(button_horizontalLayout) self.setWindowTitle(QCoreApplication.translate("about_ui_tr", "About Persepolis")) # about_tab self.title_label.setText(QCoreApplication.translate("about_ui_tr", "Persepolis Download Manager")) self.version_label.setText(QCoreApplication.translate("about_ui_tr", "Version 3.1.0")) self.site2_label.setText(QCoreApplication.translate("about_ui_tr", "<a href=https://persepolisdm.github.io>https://persepolisdm.github.io</a>", "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!")) self.telegram_label.setText(QCoreApplication.translate("about_ui_tr", "<a href=https://telegram.me/persepolisdm>https://telegram.me/persepolisdm</a>", "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!")) self.twitter_label.setText(QCoreApplication.translate("about_ui_tr", "<a href=https://twitter.com/persepolisdm>https://twitter.com/persepolisdm</a>", "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!")) #developers_tab self.developers_title_label.setText(QCoreApplication.translate('about_ui_tr', 'Developers:')) self.name_label.setText(QCoreApplication.translate("about_ui_tr", "\nAliReza AmirSamimi\nMohammadreza Abdollahzadeh\nSadegh Alirezaie\nMostafa Asadi\nMohammadAmin Vahedinia\nJafar Akhondali\nH.Rostami", "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!")) self.contributors_thank_label.setText(QCoreApplication.translate('about_ui_tr', 'Special thanks to:')) self.contributors_link_label.setText("<a href=https://github.com/persepolisdm/persepolis/graphs/contributors>our contributors</a>") # translators_tab # Chinese self.chinese_translators_label.setText(QCoreApplication.translate("about_ui_tr", "Chinese translators:")) self.chinese_translatos_name_label.setText(QCoreApplication.translate("about_ui_tr", "Davinma\n210hcl\nleoxxx")) # French self.french_translators_label.setText(QCoreApplication.translate("about_ui_tr", "French translator:")) self.french_translatos_name_label.setText(QCoreApplication.translate("about_ui_tr", "Simon Porte")) # Persian self.persian_translators_label.setText(QCoreApplication.translate("about_ui_tr", "Persian translators:")) self.persian_translatos_name_label.setText(QCoreApplication.translate("about_ui_tr", "H.Rostami\nMostafa Asadi")) # License self.license_text.setPlainText(""" This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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/. """) # tabs self.about_tabWidget.addTab(self.about_tab, QCoreApplication.translate("about_ui_tr", "About Persepolis")) self.about_tabWidget.addTab(self.developers_tab, QCoreApplication.translate("about_ui_tr", "Developers")) self.about_tabWidget.addTab(self.translators_tab, QCoreApplication.translate("about_ui_tr", "Translators")) self.about_tabWidget.addTab(self.license_tab, QCoreApplication.translate("about_ui_tr", "License")) # button self.pushButton.setText(QCoreApplication.translate("about_ui_tr", "OK"))
def setup_gettext(localedir, ui_language=None, logger=None): """Setup locales, load translations, install gettext functions.""" if not logger: logger = lambda *a, **b: None # noop current_locale = '' if ui_language: try: current_locale = locale.normalize(ui_language + '.' + locale.getpreferredencoding()) locale.setlocale(locale.LC_ALL, current_locale) except Exception as e: logger(e) else: if IS_WIN: from ctypes import windll try: current_locale = locale.windows_locale[windll.kernel32.GetUserDefaultUILanguage()] current_locale += '.' + locale.getpreferredencoding() locale.setlocale(locale.LC_ALL, current_locale) except KeyError: try: current_locale = locale.setlocale(locale.LC_ALL, '') except Exception as e: logger(e) except Exception as e: logger(e) elif IS_MACOS: try: import Foundation defaults = Foundation.NSUserDefaults.standardUserDefaults() current_locale = defaults.objectForKey_('AppleLanguages')[0] locale.setlocale(locale.LC_ALL, current_locale) except Exception as e: logger(e) else: try: current_locale = locale.setlocale(locale.LC_ALL, '') except Exception as e: logger(e) os.environ['LANGUAGE'] = os.environ['LANG'] = current_locale QLocale.setDefault(QLocale(current_locale)) logger("Using locale %r", current_locale) try: logger("Loading gettext translation, localedir=%r", localedir) trans = gettext.translation("picard", localedir) trans.install(True) _ngettext = trans.ngettext logger("Loading gettext translation (picard-countries), localedir=%r", localedir) trans_countries = gettext.translation("picard-countries", localedir) _gettext_countries = trans_countries.gettext logger("Loading gettext translation (picard-attributes), localedir=%r", localedir) trans_attributes = gettext.translation("picard-attributes", localedir) _gettext_attributes = trans_attributes.gettext except IOError as e: logger(e) builtins.__dict__['_'] = lambda a: a def _ngettext(a, b, c): if c == 1: return a else: return b def _gettext_countries(msg): return msg def _gettext_attributes(msg): return msg builtins.__dict__['ngettext'] = _ngettext builtins.__dict__['gettext_countries'] = _gettext_countries builtins.__dict__['gettext_attributes'] = _gettext_attributes logger("_ = %r", _) logger("N_ = %r", N_) logger("ngettext = %r", ngettext) logger("gettext_countries = %r", gettext_countries) logger("gettext_attributes = %r", gettext_attributes)
def setUp(self): self.setUpQuamash() QLocale.setDefault(QLocale("en_GB"))
def setUp(self): self.setUpQuamash() QLocale.setDefault(QLocale("en_GB")) self.identities_registry = IdentitiesRegistry({})
def main(args=None): if args is None: args = sys.argv[1:] parser = argparse.ArgumentParser( description='Runs the inselect user-interface' ) parser.add_argument( "file", help='The inselect document to open', nargs='?', type=Path ) parser.add_argument( '-d', '--debug', action='store_true', help='Show debug messages' ) parser.add_argument( '-l', '--locale', action='store', help='Use LOCALE; intended for dev purposes only' ) parser.add_argument( '-q', '--quit', action='store_true', help='Exit immediately after showing the main window; intended for dev ' 'purposes only' ) parser.add_argument( '-s', '--stylesheet', action='store', type=Path, help='Use stylesheet; intended for dev purposes only' ) parser.add_argument( '-t', '--print-time', action='store_true', help='Will print, when a document is closed, the elapsed time for ' 'which the document was open' ) parser.add_argument( '-v', '--version', action='version', version='%(prog)s ' + inselect.__version__ ) parser.add_argument( '-w', '--window-size', action='store', type=_window_size, help='Set window size to WxH' ) parsed = parser.parse_args(args) # TODO LH A command-line switch to clear all QSettings inselect.lib.utils.DEBUG_PRINT = parsed.debug # Only one instance of QApplication can be created per process. The single # instance is stored in QtWidgets.qApp. When test plans are being run it is # likely that the QApplication will have been created by a unittest. QtWidgets.qApp = qapplication(args) # Install global exception hook only after the application has been created sys.excepthook = report_exception_to_user debug_print('Settings stored in [{0}]'.format(QSettings().fileName())) if parsed.locale: debug_print('Will set locale to [{0}]'.format(parsed.locale)) QLocale.setDefault(QLocale(parsed.locale)) locale.setlocale(locale.LC_ALL, parsed.locale) else: # Set Python's locale module to the user's default locale locale.setlocale(locale.LC_ALL, '') debug_print('Locale is [{0}]'.format(QLocale().name())) # Application icon icon = QIcon() path = ':/icons/inselect{0}.png' for size in (16, 24, 32, 48, 64, 128, 256, 512): icon.addFile(path.format(size), QSize(size, size)) QtWidgets.qApp.setWindowIcon(icon) # Stylesheet QtWidgets.qApp.setStyleSheet(_stylesheet(parsed.stylesheet)) # Create and show main windows window = MainWindow(parsed.print_time) if parsed.window_size: window.show_with_size(parsed.window_size) else: window.show_from_geometry_settings() if parsed.file: # Process messages before loading document QtWidgets.qApp.processEvents() window.open_file(parsed.file) if parsed.quit: sys.exit(0) else: QTimer.singleShot(100, window.show_shortcuts_post_startup) sys.exit(QtWidgets.qApp.exec_())
def setUp(self): self.setUpQuamash() QLocale.setDefault(QLocale("en_GB")) ## Graph to test : ## - E ## A - B - C - D ## ## Path : Between A and C self.idA = Mock(specs='core.registry.Identity') self.idA.pubkey = "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk" self.idA.uid = "A" self.idA.is_member = CoroutineMock(spec='core.registry.Identity.is_member', return_value=True) self.idB = Mock(specs='core.registry.Identity') self.idB.pubkey = "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ" self.idB.uid = "B" self.idB.is_member = CoroutineMock(spec='core.registry.Identity.is_member', return_value=True) self.idC = Mock(specs='core.registry.Identity') self.idC.pubkey = "FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn" self.idC.uid = "C" self.idC.is_member = CoroutineMock(spec='core.registry.Identity.is_member', return_value=False) self.idD = Mock(specs='core.registry.Identity') self.idD.pubkey = "6R11KGpG6w5Z6JfiwaPf3k4BCMY4dwhjCdmjGpvn7Gz5" self.idD.uid = "D" self.idD.is_member = CoroutineMock(spec='core.registry.Identity.is_member', return_value=True) self.idE = Mock(specs='core.registry.Identity') self.idE.pubkey = "CZVDEsM6pPNxhAvXApGM8MJ6ExBZVpc8PNVyDZ7hKxLu" self.idE.uid = "E" self.idE.is_member = CoroutineMock(spec='core.registry.Identity.is_member', return_value=False) self.idA.unique_valid_certified_by = CoroutineMock(spec='core.registry.Identity.certified_by', return_value=[ { 'cert_time': 49800, 'identity': self.idB, 'block_number': 996 } ]) self.idA.unique_valid_certifiers_of = CoroutineMock(spec='core.registry.Identity.certifiers_of', return_value=[]) self.idB.unique_valid_certified_by = CoroutineMock(spec='core.registry.Identity.certified_by', return_value=[ { 'cert_time': 49100, 'identity': self.idC, 'block_number': 990 } ]) self.idB.unique_valid_certifiers_of = CoroutineMock(spec='core.registry.Identity.certifiers_of', return_value=[ { 'cert_time': 49800, 'identity': self.idA, 'block_number': 996 } ]) self.idC.unique_valid_certified_by = CoroutineMock(spec='core.registry.Identity.certified_by', return_value=[ { 'cert_time': 49100, 'identity': self.idD, 'block_number': 990 }, { 'cert_time': 49110, 'identity': self.idE, 'block_number': 990 } ]) self.idC.unique_valid_certifiers_of = CoroutineMock(spec='core.registry.Identity.certifiers_of', return_value=[ { 'cert_time': 49100, 'identity': self.idB, 'block_number': 990 } ]) self.idD.unique_valid_certified_by = CoroutineMock(spec='core.registry.Identity.certified_by', return_value=[ ]) self.idD.unique_valid_certifiers_of = CoroutineMock(spec='core.registry.Identity.certifiers_of', return_value=[ { 'cert_time': 49100, 'identity': self.idC, 'block_number': 990 }]) self.idE.unique_valid_certified_by = CoroutineMock(spec='core.registry.Identity.certified_by', return_value=[ ]) self.idE.unique_valid_certifiers_of = CoroutineMock(spec='core.registry.Identity.certifiers_of', return_value=[ { 'cert_time': 49100, 'identity': self.idC, 'block_number': 990 }])
def __init__(self, argv, qapp): ''' Create a new "cutecoin" application :param argv: The argv parameters of the call ''' super().__init__() self.accounts = {} self.current_account = None self.monitor = None self.available_version = (True, __version__, "") config.parse_arguments(argv) self._network_manager = QNetworkAccessManager() self._network_manager.finished.connect(self.read_available_version) self.preferences = {'account': "", 'lang': 'en_GB', 'ref': 0 } self.load() translator = QTranslator(qapp) logging.debug("Loading translations") locale = self.preferences['lang'] QLocale.setDefault(QLocale(locale)) if translator.load(":/i18n/{0}".format(locale)): if QCoreApplication.installTranslator(translator): logging.debug("Loaded i18n/{0}".format(locale)) else: logging.debug("Couldn't load translation")