def init(): import sys import traceback from app import helpers from app import models sys.excepthook = traceback.print_exception helpers.init_logging() helpers.init_data_dir() models.init_profile_db() models.init_data_db()
def __init__(self, args, main_widget=None): log.debug('init app') super().__init__(args) if not app.is_frozen(): sys.excepthook = traceback.print_exception self.setQuitOnLastWindowClosed(False) # Initialize application metadata locale.setlocale(locale.LC_ALL, '') try: log.debug('user locale is {}'.format( locale.getlocale(locale.LC_ALL))) except TypeError as e: log.debug(repr(e)) self.setOrganizationName(app.ORG_NAME) self.setOrganizationDomain(app.ORG_DOMAIN) self.setApplicationDisplayName(app.APP_NAME) self.setApplicationName(app.APP_NAME) self.setApplicationVersion(app.APP_VERSION) # Gui Styles and Fonts self.setStyle('fusion') font_db = QtGui.QFontDatabase() font_db.addApplicationFont(':/fonts/resources/Roboto-Light.ttf') font_db.addApplicationFont( ':/fonts/resources/RobotoCondensed-Regular.ttf') font_db.addApplicationFont( ':/fonts/resources/RobotoCondensed-Light.ttf') font_db.addApplicationFont(':/fonts/resources/RobotoMono-Light.ttf') font_db.addApplicationFont(':/fonts/resources/Oswald-Regular.ttf') font_db.addApplicationFont(':/fonts/resources/Oswald-SemiBold.ttf') app_font = QtGui.QFont("Roboto Light") app_font.setStyleStrategy(QtGui.QFont.PreferAntialias | QtGui.QFont.PreferQuality) app_font.setHintingPreference(QtGui.QFont.PreferNoHinting) self.setFont(app_font) # Instantiate workers self.updater = None self.node = None self.main_widget = main_widget if main_widget else MainWindow self.ui = None self.tray_icon = None helpers.init_data_dir() signals.application_start.connect(self.on_application_start)
def page7_sync_initialize_page(self): if self._mnemonic and not self._address: self._address = main_address_from_mnemonic(self._mnemonic) self.label_address.setText(self._address) img = ImageQt(qrcode.make(self._address, box_size=3)) self.label_qr_code.setPixmap(QPixmap.fromImage(img)) if not exists(app.DATA_DIR): self.log('Creating data dir at: %s' % app.DATA_DIR) init_data_dir() self.log('Initialize profile database at: %s' % app.PROFILE_DB_FILEPATH) with profile_session_scope() as session: if self._manage_node: Profile.create_default_profile(session) elif self._connection_tested: session.merge( Profile( name=self.edit_rpc_host.text(), rpc_host=self.edit_rpc_host.text(), rpc_port=self.edit_rpc_port.text(), rpc_user=self.edit_rpc_user.text(), rpc_password=self.edit_rpc_password.text(), rpc_use_ssl=self.cbox_use_ssl.isChecked(), manage_node=False, exit_on_close=True, active=True, )) self.log('Initialize node-sync database') init_data_db() # This fixes our problem with the locked database # We have no idea why, but we shouldn't delete this code until we have a better solution with data_session_scope() as session: session.query('DELETE FROM mining_reward') if self._manage_node: self.node.start(initprivkey=main_wif_from_mnemonic(self._mnemonic)) else: self._database_sync = True if not self.updater.isRunning(): self.updater.start()
def page7_sync_initialize_page(self): if self._mnemonic and not self._address: self._address = main_address_from_mnemonic(self._mnemonic) self.label_address.setText(self._address) img = ImageQt(qrcode.make(self._address, box_size=3)) self.label_qr_code.setPixmap(QPixmap.fromImage(img)) if not exists(app.DATA_DIR): self.log('Creating data dir at: %s' % app.DATA_DIR) init_data_dir() self.log('Initialize profile database at: %s' % app.PROFILE_DB_FILEPATH) if self._manage_node: init_profile_db(create_default_profile=True) elif self._connection_tested: init_profile_db(create_default_profile=False) p_obj, created = Profile.get_or_create( name=self.edit_rpc_host.text(), defaults=dict( rpc_host=self.edit_rpc_host.text(), rpc_port=self.edit_rpc_port.text(), rpc_user=self.edit_rpc_user.text(), rpc_password=self.edit_rpc_password.text(), rpc_use_ssl=self.cbox_use_ssl.isChecked(), manage_node=False, exit_on_close=True, active=True, ) ) self.log('Initialize node-sync database') init_data_db() if self._manage_node: self.node.start(initprivkey=main_wif_from_mnemonic(self._mnemonic)) else: self._database_sync = True if not self.updater.isRunning(): self.updater.start()
self.edit_alias.setText(self.profile.alias) self.lbl_wallet_alias.show() self.btn_wallet_alias_edit_start.show() self.btn_wallet_alias_edit_save.hide() self.btn_wallet_alias_edit_cancel.hide() self.edit_alias.hide() def save_alias(self): try: self.profile.update_alias(self.edit_alias.text()) self.stop_edit_alias() QMessageBox().information(self, "New alias", "New alias registration in progress") except Exception as e: QMessageBox().critical(self, 'Alias update error', str(e)) if __name__ == '__main__': import sys from PyQt5 import QtWidgets from app import helpers from app import models helpers.init_logging() helpers.init_data_dir() models.init_profile_db() models.init_data_db() app = QtWidgets.QApplication(sys.argv) app.setStyle('fusion') wgt = MyAccount() wgt.show() sys.exit(app.exec())
def __init__(self, **kwargs): super().__init__(**kwargs) # Instantiate workers self.updater = QApplication.instance().updater self.node = QApplication.instance().node self.data_dir = helpers.init_data_dir() self.profile_db = models.init_profile_db() self.node_data_dir = helpers.init_node_data_dir() self.data_db = models.init_data_db() self.profile = Profile.get_active() # Setup Widgets self.setupUi(self) self.on_profile_changed(self.profile) signals.profile_changed.connect(self.on_profile_changed) # Init Navigation self.btn_grp_nav.setId(self.btn_nav_wallet, 0) self.btn_grp_nav.setId(self.btn_nav_timestamp, 1) self.btn_grp_nav.setId(self.btn_nav_community, 2) self.btn_grp_nav.setId(self.btn_nav_settings, 3) self.btn_nav_wallet.setChecked(True) self.wgt_content.setCurrentIndex(0) # Patch custom widgets self.tab_widget_cummunity.setStyleSheet( 'QPushButton {padding: 5 12 5 12; font: 10pt "Roboto Light"}') self.gbox_wallet_transactions.setParent(None) self.gbox_wallet_send.setParent(None) wallet_send = WalletSend(self) self.lout_page_wallet_v.addWidget(wallet_send) wallet_history = WalletHistory(self) self.lout_page_wallet_v.addWidget(wallet_history) widget_timestamp = WidgetTimestamping(self) self.lout_page_timestamp_v.addWidget(widget_timestamp) self.table_validators.setParent(None) table_validators = CommunityTableView(self, perm_type=Permission.MINE) self.tab_validators.layout().insertWidget(0, table_validators) self.table_guardians.setParent(None) table_guardians = CommunityTableView(self, perm_type=Permission.ADMIN) self.tab_guardians.layout().insertWidget(0, table_guardians) self.table_candidates.setParent(None) table_candidates = CandidateTableView(self) self.tab_candidates.layout().insertWidget(0, table_candidates) # Dialog Button hookups invite_dialog = InviteDialog(self) self.button_invite_canditate.clicked.connect(invite_dialog.exec) apply_dialog = ApplyDialog(self) self.button_apply_guardian.clicked.connect(apply_dialog.exec) self.button_apply_validator.clicked.connect(apply_dialog.exec) # Settings self.check_box_exit_on_close.setChecked(self.profile.exit_on_close) self.check_box_exit_on_close.stateChanged['int'].connect( self.setting_changed_exit_on_close) self.check_manage_node.setChecked(self.profile.manage_node) self.check_manage_node.stateChanged['int'].connect( self.setting_changed_manage_node) # Connections signals.getblockchaininfo.connect(self.getblockchaininfo) signals.listpermissions.connect(self.listpermissions) signals.node_started.connect(self.node_started) if self.profile.manage_node: # Todo check for existing node process self.node.start() else: # No managed node to wait for... start updater self.updater.start() self.show()
def __init__(self, **kwargs): super().__init__(**kwargs) # Instantiate workers self.updater = QApplication.instance().updater self.node = QApplication.instance().node self.data_dir = helpers.init_data_dir() self.node_data_dir = helpers.init_node_data_dir() with profile_session_scope() as session: self.profile = Profile.get_active(session) # Setup Widgets self.setupUi(self) # Hide information widget font = QFont('Roboto Light', 10) self.label_info_text.setFont(font) self.btn_close_info.setFont(font) font.setUnderline(True) self.btn_info_action.setFont(font) self.widget_information.setHidden(True) self.btn_close_info.clicked.connect(self.hide_information) signals.new_unconfirmed.connect(self.show_transaction_info) self.information_type = None self.on_profile_changed(self.profile) signals.profile_changed.connect(self.on_profile_changed) self.permissions_changed() signals.permissions_changed.connect(self.permissions_changed) # Init Navigation self.btn_grp_nav.setId(self.btn_nav_wallet, 0) self.btn_grp_nav.setId(self.btn_nav_iscc, 1) self.btn_grp_nav.setId(self.btn_nav_timestamp, 2) self.btn_grp_nav.setId(self.btn_nav_token, 3) self.btn_grp_nav.setId(self.btn_nav_community, 4) self.btn_grp_nav.setId(self.btn_nav_settings, 5) self.btn_nav_wallet.setChecked(True) self.wgt_content.setCurrentIndex(0) # Patch custom widgets self.tab_widget_cummunity.setStyleSheet( 'QPushButton {padding: 5 12 5 12; font: 10pt "Roboto Light"}') self.gbox_wallet_transactions.setParent(None) self.gbox_wallet_send.setParent(None) wallet_send = WalletSend(self) self.lout_page_wallet_v.addWidget(wallet_send) wallet_history = WalletHistory(self) self.lout_page_wallet_v.addWidget(wallet_history) widget_iscc = WidgetISCC(self) self.lout_page_iscc_v.addWidget(widget_iscc) widget_timestamp = WidgetTimestamping(self) self.lout_page_timestamp_v.addWidget(widget_timestamp) widget_token = WidgetToken(self) self.lout_page_token_v.addWidget(widget_token) self.table_validators.setParent(None) table_validators = CommunityTableView(self, perm_type=enums.MINE) self.tab_validators.layout().insertWidget(0, table_validators) self.table_guardians.setParent(None) table_guardians = CommunityTableView(self, perm_type=enums.ADMIN) self.tab_guardians.layout().insertWidget(0, table_guardians) self.table_candidates.setParent(None) table_candidates = CandidateTableView(self) self.tab_candidates.layout().insertWidget(0, table_candidates) # Statusbar self.label_statusbar = QtWidgets.QLabel('') self.statusbar.addPermanentWidget(self.label_statusbar) # Dialog Button hookups invite_dialog = InviteDialog(self) self.button_invite_canditate.clicked.connect(invite_dialog.exec) apply_dialog = ApplyDialog(self) self.button_apply_guardian.clicked.connect(apply_dialog.exec) self.button_apply_validator.clicked.connect(apply_dialog.exec) # Settings self.check_box_exit_on_close.setChecked(self.profile.exit_on_close) self.check_box_exit_on_close.stateChanged['int'].connect( self.setting_changed_exit_on_close) self.check_manage_node.setChecked(self.profile.manage_node) self.check_manage_node.stateChanged['int'].connect( self.setting_changed_manage_node) self.btn_alias_change.clicked.connect(self.on_change_alias) # Connections signals.getinfo.connect(self.getinfo) signals.getblockchaininfo.connect(self.getblockchaininfo) signals.node_started.connect(self.node_started) signals.rpc_error.connect(self.rpc_error) signals.blockschanged.connect(self.getdatabaseinfo) signals.on_balance_status_changed.connect( self.on_balance_status_changed) with data_session_scope() as session: from app.models import Block self.progress_bar_database_info.setValue( session.query(Block).count()) if self.profile.manage_node: # Todo check for existing node process self.node.start() else: # No managed node to wait for... start updater self.updater.start() self.show()