コード例 #1
0
    def __init__(self, parent, imgDir):
        super(QWidget, self).__init__(parent)
        self.parent = parent
        self.imgDir = imgDir
        self.runInThread = ThreadFuns.runInThread
        ###-- Create clients and statuses
        self.hwdevice = None
        self.hwStatus = 0
        self.hwStatusMess = "Not Connected"
        self.rpcClient = None
        self.rpcConnected = False
        self.rpcStatusMess = "Not Connected"
        ###-- Load icons & images
        self.loadIcons()
        ###-- Create main layout
        self.layout = QVBoxLayout()
        self.header = GuiHeader(self)
        self.initConsole()
        self.layout.addWidget(self.header)
        ###-- Create RPC Whatchdog
        self.rpc_watchdogThread = QThread()
        self.myRpcWd = RpcWatchdog(self)
        self.myRpcWd.moveToThread(self.rpc_watchdogThread)
        self.rpc_watchdogThread.started.connect(self.myRpcWd.run)
        self.rpc_watchdogThread.start()

        ###-- Create Queues and redirect stdout and stderr (eventually)
        self.queue = Queue()
        self.queue2 = Queue()
        sys.stdout = WriteStream(self.queue)
        sys.stderr = WriteStream(self.queue2)

        ###-- Init last logs
        logFile = open(log_File, 'w+')
        timestamp = strftime('%Y-%m-%d %H:%M:%S', gmtime(now()))
        log_line = '<b style="color: blue">{}</b><br>'.format(
            'STARTING PET4L at ' + timestamp)
        logFile.write(log_line)
        logFile.close()

        ###-- Create the thread to update console log for stdout
        self.consoleLogThread = QThread()
        self.myWSReceiver = WriteStreamReceiver(self.queue)
        self.myWSReceiver.mysignal.connect(self.append_to_console)
        self.myWSReceiver.moveToThread(self.consoleLogThread)
        self.consoleLogThread.started.connect(self.myWSReceiver.run)
        self.consoleLogThread.start()
        printDbg("Console Log thread started")
        ###-- Create the thread to update console log for stderr
        self.consoleLogThread2 = QThread()
        self.myWSReceiver2 = WriteStreamReceiver(self.queue2)
        self.myWSReceiver2.mysignal.connect(self.append_to_console)
        self.myWSReceiver2.moveToThread(self.consoleLogThread2)
        self.consoleLogThread2.started.connect(self.myWSReceiver2.run)
        self.consoleLogThread2.start()
        printDbg("Console Log thread 2 started")

        ###-- Initialize tabs
        self.tabs = QTabWidget()
        self.t_rewards = TabRewards(self)
        ###-- Add tabs
        self.tabs.addTab(self.tabRewards, "Spend from Ledger")
        ###-- Draw Tabs
        self.splitter = QSplitter(Qt.Vertical)
        ###-- Add tabs and console to Layout
        self.splitter.addWidget(self.tabs)
        self.splitter.addWidget(self.console)
        self.splitter.setStretchFactor(0, 0)
        self.splitter.setStretchFactor(1, 1)
        self.splitter.setSizes([2, 1])
        self.layout.addWidget(self.splitter)
        ###-- Set Layout
        self.setLayout(self.layout)
        ###-- Let's go
        self.mnode_to_change = None
        printOK("Hello! Welcome to " + parent.title)
コード例 #2
0
ファイル: mainWindow.py プロジェクト: PIVX-Project/PET4L
    def __init__(self, parent, imgDir):
        super(QWidget, self).__init__(parent)
        self.parent = parent
        self.imgDir = imgDir
        self.runInThread = ThreadFuns.runInThread
        self.lock = threading.Lock()

        # -- Create clients and statuses
        self.hwStatus = 0
        self.hwModel = 0
        self.hwStatusMess = "Not Connected"
        self.rpcClient = None
        self.rpcConnected = False
        self.updatingRPCbox = False
        self.rpcStatusMess = "Not Connected"
        self.isBlockchainSynced = False
        # Changes when an RPC client is connected (affecting API client)
        self.isTestnetRPC = self.parent.cache['isTestnetRPC']

        # -- Load icons & images
        self.loadIcons()
        # -- Create main layout
        self.layout = QVBoxLayout()
        self.header = GuiHeader(self)
        self.initConsole()
        self.layout.addWidget(self.header)

        # -- Load RPC Servers list (init selection and self.isTestnet)
        self.updateRPClist()

        # -- Init HW selection
        self.header.hwDevices.setCurrentIndex(
            self.parent.cache['selectedHW_index'])

        # -- init HW Client
        self.hwdevice = HWdevice(self)

        # -- init Api Client
        self.apiClient = ApiClient(self.isTestnetRPC)

        # -- Create Queue to redirect stdout
        self.queue = wqueue

        # -- Init last logs
        logging.debug("STARTING PET4L")

        # -- Create the thread to update console log for stdout
        self.consoleLogThread = QThread()
        self.myWSReceiver = WriteStreamReceiver(self.queue)
        self.myWSReceiver.mysignal.connect(self.append_to_console)
        self.myWSReceiver.moveToThread(self.consoleLogThread)
        self.consoleLogThread.started.connect(self.myWSReceiver.run)
        self.consoleLogThread.start()
        printDbg("Console Log thread started")

        # -- Initialize tabs (single QLayout here)
        self.tabs = QTabWidget()
        self.t_rewards = TabRewards(self)
        # -- Add tabs
        self.tabs.addTab(self.tabRewards, self.parent.spmtIcon, "Spend")
        # -- Draw Tabs
        self.splitter = QSplitter(Qt.Vertical)
        # -- Add tabs and console to Layout
        self.splitter.addWidget(self.tabs)
        self.splitter.addWidget(self.console)
        self.splitter.setStretchFactor(0, 0)
        self.splitter.setStretchFactor(1, 1)
        self.splitter.setSizes([2, 1])
        self.layout.addWidget(self.splitter)

        # -- Set Layout
        self.setLayout(self.layout)

        # -- Init Settings
        self.initSettings()

        # -- Connect buttons/signals
        self.connButtons()

        # -- Create RPC Whatchdog
        self.rpc_watchdogThread = QThread()
        self.myRpcWd = RpcWatchdog(self)
        self.myRpcWd.moveToThread(self.rpc_watchdogThread)
        self.rpc_watchdogThread.started.connect(self.myRpcWd.run)

        # -- Let's go
        self.mnode_to_change = None
        printOK("Hello! Welcome to " + parent.title)
コード例 #3
0
    def __init__(self, parent, masternode_list, imgDir):
        super(QWidget, self).__init__(parent)
        self.parent = parent
        self.imgDir = imgDir
        self.runInThread = ThreadFuns.runInThread
        self.lock = threading.Lock()

        ###-- Masternode list
        self.masternode_list = masternode_list

        ###-- Create clients and statuses
        self.hwStatus = 0
        self.hwStatusMess = "Not Connected"
        self.rpcClient = None
        self.rpcConnected = False
        self.updatingRPCbox = False
        self.rpcStatusMess = "Not Connected"
        self.isBlockchainSynced = False

        ###-- Load icons & images
        self.loadIcons()
        ###-- Create main layout
        self.layout = QVBoxLayout()
        self.header = GuiHeader(self)
        self.initConsole()
        self.layout.addWidget(self.header)

        ##-- Load RPC Servers list
        self.updateRPClist()

        ##-- init HW Client
        self.hwdevice = HWdevice()

        ##-- init Api Client
        self.apiClient = ApiClient()

        ###-- Create Queues and redirect stdout
        self.queue = Queue()
        sys.stdout = WriteStream(self.queue)

        ###-- Init last logs
        logFile = open(log_File, 'w+')
        timestamp = strftime('%Y-%m-%d %H:%M:%S', gmtime(now()))
        log_line = '<b style="color: blue">{}</b><br>'.format(
            'STARTING SPMT at ' + timestamp)
        logFile.write(log_line)
        logFile.close()

        ###-- Create the thread to update console log for stdout
        self.consoleLogThread = QThread()
        self.myWSReceiver = WriteStreamReceiver(self.queue)
        self.myWSReceiver.mysignal.connect(self.append_to_console)
        self.myWSReceiver.moveToThread(self.consoleLogThread)
        self.consoleLogThread.started.connect(self.myWSReceiver.run)
        self.consoleLogThread.start()
        printDbg("Console Log thread started")

        ###-- Initialize tabs
        self.tabs = QTabWidget()
        self.t_main = TabMain(self)
        self.t_mnconf = TabMNConf(self)
        self.t_rewards = TabRewards(self)
        self.t_governance = TabGovernance(self)
        ###-- Add tabs
        self.tabs.setTabPosition(QTabWidget.West)
        self.tabs.addTab(self.tabMain, "Masternode List")
        #self.tabs.addTab(self.tabMNConf, "MN Configuration")
        self.tabs.addTab(self.tabRewards, "Rewards")
        self.tabs.addTab(self.tabGovernance, "Governance")
        ###-- Connect change action
        self.tabs.currentChanged.connect(lambda: self.onTabChange())
        ###-- Draw Tabs
        self.splitter = QSplitter(Qt.Vertical)
        ###-- Add tabs and console to Layout
        self.splitter.addWidget(self.tabs)
        self.splitter.addWidget(self.console)
        self.splitter.setStretchFactor(0, 0)
        self.splitter.setStretchFactor(1, 1)
        self.layout.addWidget(self.splitter)

        ###-- Set Layout
        self.setLayout(self.layout)

        ###-- Init Settings
        self.initSettings()

        ###-- Connect buttons/signals
        self.connButtons()

        ##-- Check version
        self.onCheckVersion()

        ###-- Create RPC Whatchdog
        self.rpc_watchdogThread = QThread()
        self.myRpcWd = RpcWatchdog(self)
        self.myRpcWd.moveToThread(self.rpc_watchdogThread)
        self.rpc_watchdogThread.started.connect(self.myRpcWd.run)

        ###-- Let's go
        self.mnode_to_change = None
        printOK("Hello! Welcome to " + parent.title)
コード例 #4
0
 def __init__(self, parent, masternode_list, imgDir):
     super(QWidget, self).__init__(parent)
     self.parent = parent
     self.imgDir = imgDir 
     self.runInThread = ThreadFuns.runInThread
     ###-- Masternode list 
     self.masternode_list = masternode_list      
     ###-- Create clients and statuses
     self.hwdevice = None
     self.hwStatus = 0
     self.hwStatusMess = "Not Connected"
     self.rpcClient = None
     self.rpcConnected = False
     self.rpcStatusMess = "Not Connected"
     self.isBlockchainSynced = False      
     ###-- Load icons & images
     self.loadIcons()        
     ###-- Create main layout
     self.layout = QVBoxLayout()
     self.header = GuiHeader(self)
     self.initConsole()
     self.layout.addWidget(self.header)       
     ###-- Create RPC Whatchdog
     self.rpc_watchdogThread = QThread()
     self.myRpcWd = RpcWatchdog(self)
     self.myRpcWd.moveToThread(self.rpc_watchdogThread)
     self.rpc_watchdogThread.started.connect(self.myRpcWd.run)
     self.rpc_watchdogThread.start()       
     
     ###-- Create Queues and redirect stdout and stderr (eventually)
     self.queue = Queue()
     self.queue2 = Queue()
     sys.stdout = WriteStream(self.queue)
     sys.stderr = WriteStream(self.queue2)  
   
     
     ###-- Init last logs
     logFile = open(log_File, 'w+')
     timestamp = strftime('%Y-%m-%d %H:%M:%S', gmtime(now()))
     log_line = '<b style="color: blue">{}</b><br>'.format('STARTING SPMT at '+ timestamp)
     logFile.write(log_line)
     logFile.close()
     
     ###-- Create the thread to update console log for stdout
     self.consoleLogThread = QThread()
     self.myWSReceiver = WriteStreamReceiver(self.queue)
     self.myWSReceiver.mysignal.connect(self.append_to_console)
     self.myWSReceiver.moveToThread(self.consoleLogThread)
     self.consoleLogThread.started.connect(self.myWSReceiver.run)
     self.consoleLogThread.start()
     printDbg("Console Log thread started")
     ###-- Create the thread to update console log for stderr
     self.consoleLogThread2 = QThread()
     self.myWSReceiver2 = WriteStreamReceiver(self.queue2)
     self.myWSReceiver2.mysignal.connect(self.append_to_console)
     self.myWSReceiver2.moveToThread(self.consoleLogThread2)
     self.consoleLogThread2.started.connect(self.myWSReceiver2.run)
     self.consoleLogThread2.start()
     printDbg("Console Log thread 2 started")       
     
     ###-- Initialize tabs
     self.tabs = QTabWidget()
     self.t_main = TabMain(self)
     self.t_mnconf = TabMNConf(self)
     self.t_rewards = TabRewards(self)
     
     ###-- Add tabs
     self.tabs.addTab(self.tabMain, "Masternode Control")
     #self.tabs.addTab(self.tabMNConf, "MN Configuration")
     self.tabs.addTab(self.tabRewards, "Transfer Rewards")              
     ###-- Connect change action
     self.tabs.currentChanged.connect(lambda: self.onTabChange())                    
     ###-- Draw Tabs 
     self.splitter = QSplitter(Qt.Vertical)
     ###-- Add tabs and console to Layout        
     self.splitter.addWidget(self.tabs)
     self.splitter.addWidget(self.console)
     self.splitter.setStretchFactor(0,0)
     self.splitter.setStretchFactor(1,1)
     self.splitter.setSizes(self.parent.cache.get("splitter_sizes"))
     self.layout.addWidget(self.splitter)
     
     ###-- Set Layout
     self.setLayout(self.layout)
     ###-- Let's go
     self.mnode_to_change = None
     printOK("Hello! Welcome to " + parent.title)
     
     ###-- Hide console if it was previously hidden
     if self.parent.cache.get("console_hidden"):
         self.onToggleConsole()
         
     ##-- Check version
     self.onCheckVersion()
コード例 #5
0
    def __init__(self, parent, masternode_list, imgDir):
        super(QWidget, self).__init__(parent)
        self.parent = parent
        self.imgDir = imgDir
        self.runInThread = ThreadFuns.runInThread
        self.lock = threading.Lock()

        ###-- Masternode list
        self.masternode_list = masternode_list

        ###-- Create clients and statuses
        self.hwStatus = 0
        self.hwModel = 0
        self.hwStatusMess = "Not Connected"
        self.rpcClient = None
        self.rpcConnected = False
        self.updatingRPCbox = False
        self.rpcStatusMess = "Not Connected"
        self.isBlockchainSynced = False
        # Changes when an RPC client is connected (affecting API client)
        self.isTestnetRPC = self.parent.cache['isTestnetRPC']

        ###-- Load icons & images
        self.loadIcons()
        ###-- Create main layout
        self.layout = QVBoxLayout()
        self.header = GuiHeader(self)
        self.initConsole()
        self.layout.addWidget(self.header)

        ##-- Load RPC Servers list (init selection and self.isTestnet)
        self.updateRPClist()

        ##-- Init HW selection
        self.header.hwDevices.setCurrentIndex(
            self.parent.cache['selectedHW_index'])

        ##-- init HW Client
        self.hwdevice = HWdevice(self)

        ##-- init Api Client
        self.apiClient = ApiClient(self.isTestnetRPC)

        ###-- Create Queues and redirect stdout
        self.queue = Queue()
        sys.stdout = WriteStream(self.queue)

        ###-- Init last logs
        logging.debug("STARTING SPMT")

        ###-- Create the thread to update console log for stdout
        self.consoleLogThread = QThread()
        self.myWSReceiver = WriteStreamReceiver(self.queue)
        self.myWSReceiver.mysignal.connect(self.append_to_console)
        self.myWSReceiver.moveToThread(self.consoleLogThread)
        self.consoleLogThread.started.connect(self.myWSReceiver.run)
        self.consoleLogThread.start()
        printDbg("Console Log thread started")

        ###-- Initialize tabs
        self.tabs = QTabWidget()
        self.t_main = TabMain(self)
        self.t_mnconf = TabMNConf(self)
        self.t_rewards = TabRewards(self)
        self.t_governance = TabGovernance(self)

        ###-- Add tabs
        self.tabs.setTabPosition(QTabWidget.West)
        self.tabs.addTab(self.tabMain, "Masternode List")
        #self.tabs.addTab(self.tabMNConf, "MN Configuration")
        self.tabs.addTab(self.tabRewards, "Rewards")
        self.tabs.addTab(self.tabGovernance, "Governance")

        ###-- Connect change action
        self.tabs.currentChanged.connect(lambda: self.onTabChange())

        ###-- Add tabs and console to Layout
        self.splitter = QSplitter(Qt.Vertical)
        self.splitter.addWidget(self.tabs)
        self.splitter.addWidget(self.console)
        self.splitter.setStretchFactor(0, 0)
        self.splitter.setStretchFactor(1, 1)
        self.layout.addWidget(self.splitter)

        ###-- Set Layout
        self.setLayout(self.layout)

        ###-- Init Settings
        self.initSettings()

        ###-- Connect buttons/signals
        self.connButtons()

        ##-- Check version
        self.onCheckVersion()

        ###-- Create RPC Whatchdog
        self.rpc_watchdogThread = QThread()
        self.myRpcWd = RpcWatchdog(self)
        self.myRpcWd.moveToThread(self.rpc_watchdogThread)
        self.rpc_watchdogThread.started.connect(self.myRpcWd.run)

        ###-- Let's go
        self.mnode_to_change = None
        printOK("Hello! Welcome to " + parent.title)