Beispiel #1
0
class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
    '''
    this is the tray icon application 
    1. show a splash with text with Cmd-1
    2. exit with Exit 
    '''
    def __init__(self, icon, parent=None):
        QtWidgets.QSystemTrayIcon.__init__(self, icon, parent)
        #create the menu
        menu = QtWidgets.QMenu(parent)

        #create the exit function
        exitAction = menu.addAction("Exit")
        cmd1Action = menu.addAction("Cmd-1")
        self.setContextMenu(menu)
        #triggered exit
        exitAction.triggered.connect(self.exit)
        #triggered exit
        cmd1Action.triggered.connect(self.cmd1)

    def quit(self):
        QtCore.QCoreApplication.exit()

    # create the exit application
    def exit(self):
        QtCore.QCoreApplication.exit()

    # create a command 1
    def cmd1(self):
        print("command 1")
        self.splash = SplashScreen()
        self.splash.showMessage("Test...")
        self.splash.show()
Beispiel #2
0
    def start_splash_screen(self, hardware_selection):
        self.splash_screen = SplashScreen(self)

        # Create textLogger
        self.splash_log_text_handler = TextHandler(self.splash_screen.txt)

        # Add the handler to logger
        self.splash_logger = logging.getLogger()
        self.splash_logger.setLevel(logging.INFO)
        formatter = logging.Formatter('%(asctime)s :: %(levelname)s :: %(message)s')
        self.splash_log_text_handler.setFormatter(formatter)
        self.splash_logger.addHandler(self.splash_log_text_handler)

        time.sleep(0.5)

        self.create_hardware(hardware_selection)
        self.splash_screen.set_exit_btn_ok()
        self.is_hardware_loaded = True

        # self.createMidiControl()



        self.create_gui()
        self.launch_ctrl()
        self.close_splash_screen()
Beispiel #3
0
def initData():
    # 模拟后台初始化其他数据
    SplashScreen.sendMessage(formatText('初始化其他数据', 'red'))
    sleep(2)

    for i in range(1, 101):
        SplashScreen.sendMessage(
            formatText('加载模型中...{0}%'.format(i), 'green', i))
        sleep(0.1)
Beispiel #4
0
    def init(self):
        self.bgColor = (0, 0, 0)

        # initialize splash
        SplashScreen.init()
        self.logo = SplashScreen(self.width, self.height)

        # initialize intro
        Intro.init()
        self.intro = Intro()

        # initialize box
        ActionBox.init()
        self.actionBox = ActionBox()

        #initialize music
        self.startMusic = True
        Music.init()
        self.sounds = Music()
Beispiel #5
0
    def __init__(self):
        self.input = Input()
        self.game_brain = GameBrain()
        self.resource = Resource()
        pygame.init()
        screen = pygame.display.set_mode((Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT))
        pygame.display.set_caption("Twister!")

        states = {"SPLASH": SplashScreen(self.input, self.game_brain),
                       "GAMEPLAY": Gameplay(self.input, self.game_brain, self.resource),
                       "SHOW_CHALLENGE_SCORE": ShowChallengeScore(self.input, self.game_brain, self.resource),
                       "SHOW_FINAL_SCORE": ShowFinalScore(self.input, self.game_brain, self.resource)}
        game = Game(screen, states, "SPLASH")
        game.run()
        pygame.quit()
        sys.exit()
Beispiel #6
0
    def __init__(self, *args, **kwargs):
        super(Window, self).__init__(*args, **kwargs)
        # 模拟界面初始化
        sleep(2)
        SplashScreen.sendMessage(formatText('UI初始化完成', 'white'))
        sleep(2)

        # 模拟加载其它数据
        t = Thread(target=initData, daemon=True)
        t.start()
        t.join()

        # 加载完成发送退出
        SplashScreen.sendMessage(
            json.dumps({
                'text': 'exit',
                'progress': 0
            }) + '\n')
        SplashScreen.disconnect()
Beispiel #7
0
# -*- coding: utf-8 -*-
""" start.py

This file launches the wallet and starts the main GTK loop.
"""

import signal
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from SplashScreen import SplashScreen

signal.signal(
    signal.SIGINT,
    signal.SIG_DFL)  # Required to handle interrupts closing the program
splash_screen = SplashScreen()  # Create a new instance of the splash screen
Gtk.main()  # Start the main GTK loop
Beispiel #8
0
def start_RepTate(argv):
    """
    Main RepTate application. 
    
    :param list argv: Command line parameters passed to Reptate
    """
    GUI = True

    parser = argparse.ArgumentParser(
        description='RepTate: Rheologhy of Entangled Polymers: Toolkit for the Analysis of Theory and Experiment.',
        epilog='(c) Jorge Ramirez - [email protected] - UPM , Victor Boudara - U. Leeds (2018)')
    parser.add_argument('-d', '--dpi', help='High DPI support on Windows', action='store_true')
    parser.add_argument('-s', '--single', help='Run Reptate as a single thread application', action='store_true')
    parser.add_argument('-v', '--verbose', help='Write debug information to stdout', action='store_true')
    parser.add_argument('-V', '--version', help='Print RepTate version and exit', action='store_true')
    parser.add_argument('finlist', nargs='*')

    args = parser.parse_args(args=argv) 

    # Get files from command line
    dictfiles=get_argument_files(args.finlist)

    if args.version:
        print(QApplicationManager.intro)
        sys.exit()

    QApplication.setStyle("Fusion") #comment that line for a native look
                                    #for a list of available styles: "from PyQt5.QtWidgets import QStyleFactory; print(QStyleFactory.keys())"

    if args.dpi:
        os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"
        QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
        QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
        QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True)

    app = QApplication(sys.argv)
    #if args.dpi:
    #    app.setAttribute(Qt.AA_EnableHighDpiScaling)
    
    splash = SplashScreen()
    # splash.showMessage("Loading RepTate...\n")
    splash.show()
    
    # FOR DEBUGGING PURPOSES: Set Single or MultiThread (default)
    if args.single:
        CmdBase.calcmode = CalcMode.singlethread

    ex = QApplicationManager()
    ex.setStyleSheet("QTabBar::tab { color:black; height: 22px; }")
    # splash.showMessage("Loading RepTate...")

    splash.finish(ex)

    # Handle files & open apps accordingly
    CmdBase.calcmode = CalcMode.singlethread # avoid troubles when loading multiple apps/files/theories
    d = {ex.extension: ex.appname for ex in  list(ex.available_applications.values())}
    for k in dictfiles.keys():
        if k == 'rept':
            ex.open_project(dictfiles[k][0])
        elif np.any([k == key for key in d.keys()]):
            # exact match
            ex.handle_new_app(d[k])
            appname="%s%d"%(d[k],ex.application_counter)
            ex.applications[appname].new_tables_from_files(dictfiles[k])      
        elif np.any([k in key for key in d.keys()]): # works with spaces in extensions
            for key in d.keys():
                if k in key:
                    ex.handle_new_app(d[key])
                    appname="%s%d"%(d[key],ex.application_counter)
                    ex.applications[appname].new_tables_from_files(dictfiles[k])
                    break
        else:
            print("File type %s cannot be opened"%k)
    # set the calmode back
    if args.single:
        CmdBase.calcmode = CalcMode.singlethread
    else:
        CmdBase.calcmode = CalcMode.multithread

    def my_excepthook(type, value, tb):
        """Catch exceptions and print error message. Open email client to report bug to devlopers"""
        tb_msg = ''
        for e in traceback.format_tb(tb):
            tb_msg += str(e)
        tb_msg += "%s: %s\n" % (type.__name__, str(value))
        print(tb_msg)
        msg = 'Sorry, something went wrong:\n \"%s: %s\".\nTry to save your work and quit RepTate.\nDo you want to help RepTate developers by reporting this bug?' % (type.__name__, str(value))
        ans = QMessageBox.critical(ex, 'Critical Error', msg, QMessageBox.Yes | QMessageBox.No )
        if ans == QMessageBox.Yes:
            address = "*****@*****.**"
            subject = "Something went wrong"
            body = "%s\nIf you can, please describe below what you were doing with RepTate when the error happened (apps and theories or tools open if any) and send the message\nPlease, do NOT include confidential information\n%s\nError Traceback:\n %s" % ("-"*60, "-"*60 + "\n"*10 + "-"*60,  tb_msg)
            QDesktopServices.openUrl(QUrl("mailto:?to=%s&subject=%s&body=%s" % (address, subject, body), QUrl.TolerantMode))
            
    sys.excepthook = my_excepthook

    ex.showMaximized()
    sys.exit(app.exec_())
Beispiel #9
0
    def check_ads(self):
        try:
            self.tc.check_ads(self.sourceUrl, 1)
        except BaseException, e:
            print(str(e))
            return

    def closeEvent(self, QCloseEvent):
        self.writeSettings()
        self.logFile.close()

    def __del__(self):
        self.writeSettings()
        self.logFile.close()


if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    # splash=QtGui.QSplashScreen(QtGui.QPixmap(':/tumload.png'))
    # splash.show()
    splash = SplashScreen()
    # splash.effective()
    splash.effect()
    # splash.effect_show()
    app.processEvents()
    window = TumloadClass()
    # splash.checkEnd()
    window.show()
    splash.finish(window)
    sys.exit(app.exec_())
# -*- coding: utf-8 -*-

##  GUI应用程序主程序入口

import sys

from PySide2.QtWidgets import QApplication
from SplashScreen import SplashScreen

from Windows import MainWindow

app = QApplication(sys.argv)  # 创建GUI应用程序
splash = SplashScreen()

mainWindow = MainWindow()  # 创建主窗体

mainWindow.show()  # 显示主窗体

sys.exit(app.exec_())
Beispiel #11
0
class Game(PygameGame):

    # mode changes throughout game for display
    MODE = 'Title Screen'
    # possible modes: Title Screen, Credits, Intro, Wheel, Trust/Forsake, Battle
    TIMEKEEP = 0

    def init(self):
        self.bgColor = (0, 0, 0)

        # initialize splash
        SplashScreen.init()
        self.logo = SplashScreen(self.width, self.height)

        # initialize intro
        Intro.init()
        self.intro = Intro()

        # initialize box
        ActionBox.init()
        self.actionBox = ActionBox()

        #initialize music
        self.startMusic = True
        Music.init()
        self.sounds = Music()

    def keyPressed(self, code, mod):

        # change music volume
        if code == pygame.K_EQUALS:
            Music.changeVol(0.05)
        elif code == pygame.K_MINUS:
            Music.changeVol(-0.05)

        # start game, view credits
        if Game.MODE == 'Title Screen':
            if code == pygame.K_RETURN:
                Game.MODE = 'Intro'
                self.startMusic = True
            elif code == pygame.K_SPACE:
                Game.MODE = 'Credits'

        elif Game.MODE == 'Credits':
            if code == pygame.K_ESCAPE:
                Game.MODE = 'Title Screen'

        # skip intro
        elif Game.MODE == 'Intro':
            if code == pygame.K_RETURN:
                Game.MODE = 'Wheel'
                self.startMusic = True

    def timerFired(self, dt):
        Game.TIMEKEEP += 1

        # music player
        if self.startMusic == True:
            self.sounds.startMusic(Game.MODE)
            self.startMusic = False
            #MUST RESET self.startMusic WHEN NEXT ROUND STARTS

        # allows letter by letter text crawl
        if Game.MODE == 'Intro':
            if Game.TIMEKEEP % 2 == 0:
                self.intro.crawlText(Game.TIMEKEEP)

    def redrawAll(self, screen):
        if Game.MODE == 'Title Screen':
            self.logo.drawLogos(screen)

        elif Game.MODE == 'Credits':
            self.logo.drawCredits(screen)

        elif Game.MODE == 'Intro':
            self.intro.drawText(screen)
            self.actionBox.draw(screen)
Beispiel #12
0
class Installer:

    SHOW_BUTTON_FINISH = 1
    SHOW_BUTTON_FORWARD = 1
    SHOW_BUTTON_BACK = 1
    SHOW_BUTTON_HELP = 1
    SHOW_BUTTON_EXIT = 1
    install_profile_xml_file = ""
    install_window = None

    menuItems = [
        {
            'text': _('Welcome'),
            'module': __import__("Welcome")
        },
        {
            'text': _('Pre-install Config'),
            'module': __import__("ClientConfig")
        },
        {
            'text': _('Partitioning'),
            'module': __import__("Partitioning")
        },
        {
            'text': _('Network Mounts'),
            'module': __import__("NetworkMounts")
        },
        #                  { 'text': _('Stage'), 'module': __import__("Stage") },
        {
            'text': _('Portage tree'),
            'module': __import__("PortageTree")
        },
        #                  { 'text': _('make.conf'), 'module': __import__("MakeDotConf") },
        #                  { 'text': _('Kernel'), 'module': __import__("Kernel") },
        {
            'text': _('Bootloader'),
            'module': __import__("Bootloader")
        },
        {
            'text': _('Timezone'),
            'module': __import__("Timezone")
        },
        {
            'text': _('Networking'),
            'module': __import__("Networking")
        },
        #                  { 'text': _('Daemons'), 'module': __import__("Daemons") },
        #                  { 'text': _('Extra Packages'), 'module': __import__("ExtraPackages") },
        #                  { 'text': _('Startup Services'), 'module': __import__("StartupServices") },
        {
            'text': _('Other Settings'),
            'module': __import__("OtherSettings")
        },
        {
            'text': _('Users'),
            'module': __import__("Users")
        },
        {
            'text': _('Review'),
            'module': __import__("InstallSummary")
        }
    ]

    def __init__(self):
        self.client_profile = GLIClientConfiguration.ClientConfiguration()
        self.install_profile = GLIInstallProfile.InstallProfile()
        self._pretend = False
        self._debug = False

        for arg in sys.argv:
            if arg == "-p" or arg == "--pretend":
                self._pretend = True
            elif arg == "-d" or arg == "--debug":
                self._debug = True

        self.cc = GLIClientController.GLIClientController(
            pretend=self._pretend)

        self.window = None
        self.panel = None
        self._cur_panel = 0
        self.__full_path = self.get_current_path()
        self.splash = SplashScreen(self.__full_path)
        self.splash.show()
        while gtk.events_pending():
            gtk.main_iteration()
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.title = _("Gentoo Linux Installer")
        self.window.realize()
        self.window.connect("delete_event", self.delete_event)
        self.window.connect("destroy", self.destroy)
        self.window.set_border_width(0)
        self.window.set_default_size(800, 600)
        self.window.set_geometry_hints(None,
                                       min_width=800,
                                       min_height=600,
                                       max_width=800,
                                       max_height=600)
        self.window.set_title(_("Gentoo Linux Installer"))
        self.globalbox = gtk.VBox(False, 0)
        self.window.add(self.globalbox)

        # Banner image
        self.headerbox = gtk.HBox(False, 0)
        headerimg = gtk.Image()
        headerimg.set_from_file(self.__full_path +
                                '/installer-banner-800x64.png')
        self.headerbox.add(headerimg)
        self.globalbox.pack_start(self.headerbox,
                                  expand=False,
                                  fill=False,
                                  padding=0)

        # Future bar
        self.futurebar = GLIFutureBar(
            [element['text'] for element in self.menuItems])
        self.globalbox.pack_start(self.futurebar,
                                  expand=False,
                                  fill=False,
                                  padding=5)
        self.globalbox.pack_start(gtk.HSeparator(),
                                  expand=False,
                                  fill=False,
                                  padding=0)

        # Top box
        self.topbox = gtk.HBox(False, 0)
        self.globalbox.pack_start(self.topbox,
                                  expand=True,
                                  fill=True,
                                  padding=5)

        # Bottom box
        self.bottombox = gtk.HBox(False, 0)
        self.globalbox.pack_end(self.bottombox,
                                expand=False,
                                fill=False,
                                padding=5)
        self.globalbox.pack_end(gtk.HSeparator(),
                                expand=False,
                                fill=False,
                                padding=0)
        self.rightframe = gtk.VBox(False, 0)
        self.topbox.pack_end(self.rightframe,
                             expand=True,
                             fill=True,
                             padding=5)
        self.globalbox.show_all()

        # Right frame contents
        self.panels = []
        self.right_pane_box = gtk.Notebook()
        #		for item in self.menuItems:
        #			if item['module'] == None: break
        #			if self._debug:
        #				print "Instantiating " + item['text'] + " screen...",
        #			panel = item['module'].Panel(self)
        #			if self._debug:
        #				print "done"
        #			self.panels.append(panel)
        #			self.right_pane_box.append_page(panel)
        self.right_pane_box.set_show_tabs(False)
        self.right_pane_box.set_show_border(False)
        self.rightframe.add(self.right_pane_box)

        buttons_info = [
            ('exit', _(" _Exit "), '/button_images/stock_exit.png',
             self.exit_button, 'start'),
            ('help', _(" _Help "), '/button_images/stock_help.png', self.help,
             'start'),
            ('load', _(" _Load "), '/button_images/stock_open.png',
             self.load_button, 'start'),
            ('save', _(" _Save "), '/button_images/stock_save.png',
             self.save_button, 'start'),
            ('finish', _(" _Install "), '/button_images/stock_exec.png',
             self.finish, 'end'),
            ('forward', _(" _Forward "), '/button_images/stock_right.png',
             self.forward, 'end'),
            ('back', _(" _Back "), '/button_images/stock_left.png', self.back,
             'end')
        ]
        self.buttons = {}

        for button in buttons_info:
            self.buttons[button[0]] = gtk.Button()
            tmpbuttonbox = gtk.HBox(False, 0)
            tmpbuttonimg = gtk.Image()
            tmpbuttonimg.set_from_file(self.__full_path + button[2])
            tmpbuttonbox.pack_start(tmpbuttonimg)
            tmpbuttonlabel = gtk.Label(button[1])
            tmpbuttonlabel.set_use_underline(True)
            tmpbuttonbox.pack_start(tmpbuttonlabel)
            self.buttons[button[0]].add(tmpbuttonbox)
            self.buttons[button[0]].connect("clicked", button[3], None)
            if button[4] == "start":
                self.bottombox.pack_start(self.buttons[button[0]],
                                          expand=False,
                                          fill=False,
                                          padding=5)
            else:
                self.bottombox.pack_end(self.buttons[button[0]],
                                        expand=False,
                                        fill=False,
                                        padding=5)

        gobject.idle_add(self.init_screens)

    def redraw_left_pane(self, firstrun=False):
        if not firstrun: self.leftframe.remove(self.navlinks)
        self.navlinks = gtk.VBox(False, 5)
        self.navlinks.set_size_request(140, -1)
        navlinkslabel = gtk.Label(_("    Installation Steps    "))
        self.navlinks.pack_start(navlinkslabel,
                                 expand=False,
                                 fill=False,
                                 padding=10)
        self.num_times = 0
        for item_ in self.menuItems:
            item = str(self.num_times + 1) + ". " + item_['text']
            self.box = gtk.HBox(False, 5)
            box_string = item
            box_label = gtk.Label(box_string)
            box_label.set_alignment(0, 0)
            self.box.pack_start(box_label, expand=False, fill=False, padding=5)
            self.navlinks.pack_start(self.box,
                                     expand=False,
                                     fill=False,
                                     padding=3)
            box_label.set_sensitive(True)

            if self._cur_panel == self.num_times:
                box_label.set_markup('<b>' + box_string + '</b>')

            self.num_times = self.num_times + 1
        self.leftframe.add(self.navlinks)
        self.leftframe.show_all()

    def redraw_buttons(self):
        self.bottombox.hide_all()
        self.buttons['finish'].set_sensitive(self.SHOW_BUTTON_FINISH)
        self.buttons['forward'].set_sensitive(self.SHOW_BUTTON_FORWARD)
        self.buttons['back'].set_sensitive(self.SHOW_BUTTON_BACK)
        self.buttons['help'].set_sensitive(self.SHOW_BUTTON_HELP)
        self.buttons['exit'].set_sensitive(self.SHOW_BUTTON_EXIT)
        if self.SHOW_BUTTON_FORWARD:
            self.buttons['forward'].set_flags(gtk.CAN_DEFAULT)
            self.buttons['forward'].grab_default()
        elif self.SHOW_BUTTON_FINISH:
            self.buttons['finish'].set_flags(gtk.CAN_DEFAULT)
            self.buttons['finish'].grab_default()


#		if self.install_profile_xml_file != "":
#			self.finishbutton.set_sensitive(True)
        self.bottombox.show_all()

    def refresh_right_panel(self):
        self.rightframe.show_all()

    def make_visible(self):
        self.window.show_all()
        self.window.present()

    def make_invisible(self):
        self.window.hide_all()

    def get_current_path(self):
        # this will return the absolute path to the
        # directory containing this file
        # it will only work if this file is imported somewhere,
        # not if it is run directly (__file__ will be undefined)
        import os.path
        return os.path.abspath(os.path.dirname(__file__))

    def add_content(self, content):
        self.right_pane_box.pack_end(content, True, True, 0)

    def get_commands(self):
        pass

    def set_active(self):
        self.active = 1

    def loadPanel(self, panel=0):
        if not self.panels[self._cur_panel].deactivate():
            return
        self._cur_panel = panel
        self.right_pane_box.set_current_page(panel)
        self.panels[panel].activate()
        self.futurebar.setpos(panel)
        self.redraw_buttons()

    def init_screens(self):
        #		self.splash.show()
        for item in self.menuItems:
            if item['module'] == None: break
            if self._debug:
                print "Instantiating " + item['text'] + " screen...",
            panel = item['module'].Panel(self)
            if self._debug:
                print "done"
            self.panels.append(panel)
            self.right_pane_box.append_page(panel)
        self.splash.destroy()
        self.make_visible()
        self.loadPanel()
        return False

    def run(self):
        gtk.threads_init()
        gtk.main()

    def back(self, widget, data=None):
        if self._cur_panel > 0:
            self.loadPanel(self._cur_panel - 1)

    def forward(self, widget, data=None):
        if self._cur_panel < (len(self.menuItems) - 1):
            self.loadPanel(self._cur_panel + 1)

    def help(self, widget, data=None):
        #		GLIUtility.spawn("firefox http://www.gentoo.org/doc/en/handbook/index.xml &>/dev/null &")
        try:
            helptext = self.panels[self._cur_panel]._helptext
        except:
            helptext = "There is no help available for this screen"
        helpdlg = HelpDialog(self.window, helptext)
        helpdlg.run()

    def exit_button(self, widget, data=None):
        msgdlg = gtk.MessageDialog(
            parent=self.window,
            type=gtk.MESSAGE_QUESTION,
            buttons=gtk.BUTTONS_YES_NO,
            message_format="Are you sure you want to exit?")
        resp = msgdlg.run()
        msgdlg.destroy()
        if resp == gtk.RESPONSE_YES:
            self.exit()

    def finish(self, widget, data=None):
        # Remove screens
        while len(self.panels):
            self.right_pane_box.remove_page(-1)
            del self.panels[-1]
        self.make_invisible()
        self.install_window = RunInstall.RunInstall(self)

    def load_button(self, widget, data=None):
        filesel = gtk.FileSelection(_("Select the install profile to load"))
        if self.install_profile_xml_file == "":
            filesel.set_filename("installprofile.xml")
        else:
            filesel.set_filename(self.install_profile_xml_file)
        resp = filesel.run()
        filename = filesel.get_filename()
        filesel.destroy()
        if resp == gtk.RESPONSE_OK:
            self.install_profile_xml_file = filename
            try:
                tmp_install_profile = GLIInstallProfile.InstallProfile()
                tmp_install_profile.parse(self.install_profile_xml_file)
                self.install_profile = tmp_install_profile
                msgdlg = gtk.MessageDialog(
                    parent=self.window,
                    type=gtk.MESSAGE_INFO,
                    buttons=gtk.BUTTONS_OK,
                    message_format=_("Install profile loaded successfully!"))
                msgdlg.run()
                msgdlg.destroy()
            except:
                errdlg = gtk.MessageDialog(
                    parent=self.window,
                    type=gtk.MESSAGE_ERROR,
                    buttons=gtk.BUTTONS_OK,
                    message_format=_(
                        "An error occured loading the install profile"))
                errdlg.run()
                errdlg.destroy()

    def save_button(self, widget, data=None):
        filesel = gtk.FileSelection(
            _("Select the location to save the install profile"))
        if self.install_profile_xml_file == "":
            filesel.set_filename("installprofile.xml")
        else:
            filesel.set_filename(self.install_profile_xml_file)
        resp = filesel.run()
        filename = filesel.get_filename()
        filesel.destroy()
        if resp == gtk.RESPONSE_OK:
            self.install_profile_xml_file = filename
            try:
                configuration = open(filename, "w")
                configuration.write(self.install_profile.serialize())
                configuration.close()
                msgdlg = gtk.MessageDialog(
                    parent=self.window,
                    type=gtk.MESSAGE_INFO,
                    buttons=gtk.BUTTONS_OK,
                    message_format=_("Install profile saved successfully!"))
                msgdlg.run()
                msgdlg.destroy()
            except:
                errdlg = gtk.MessageDialog(
                    parent=self.window,
                    type=gtk.MESSAGE_ERROR,
                    buttons=gtk.BUTTONS_OK,
                    message_format=_(
                        "An error occured saving the install profile"))
                errdlg.run()
                errdlg.destroy()

    def delete_event(self, widget, event, data=None):
        return False

    def destroy(self, widget, data=None):
        gtk.main_quit()
        return True

    def exit(self):
        gtk.main_quit()
        sys.exit(0)
Beispiel #13
0
 def cmd1(self):
     print("command 1")
     self.splash = SplashScreen()
     self.splash.showMessage("Test...")
     self.splash.show()
Beispiel #14
0
class macGuiver():
    def __init__(self):
        self.root = tk.Tk()
        # self.mmc = None

        self.menu = Menu(self.root, self)

        self.is_hardware_loaded = False

        self.hardware_label_dict = {
            'MCL XY': MCL_XY.madLibCity_XY,
            'Standa XY': Standa_XY.Standa_XY,
            'Arduino Counting':  ArduinoCounting.ArduinoCouting,
            'XY Scanner': xy_scanner.XYScanner,
            'Joystick control': tk.IntVar(0),
            'Elveflow OB1': tk.IntVar(0),
            'Fianium (Work In progress)': tk.IntVar(0),
            'Spectro (Work In progress)': Spectro.Spectro,
            'Arduino Pulser': tk.IntVar(0),
            'FPGA Nist': tk.IntVar(0),
            'Thorlabs Filter Slider': tk.IntVar(0),
            'Valve Manager': tk.IntVar(0),
        }


        self.config = Config()
        self.listHardware = []
        # As for now, we don't need micromanager anymore.
        # self.launch_MicroManager()
        self.splash_screen = None
        # self.start_splash_screen()
        # self.root.update()

        self.save_dir = ""

        self.joystick_listener = None
        self.madLibCity_XY = None

        self.select_hardware_frame = SelectHardwareWindow(self)

        # We have to create a thread to update the GUI. Indeed, there is still no "main loop" for the tkinter app
        # but we already want to have some info on the harware initialization. Hence this small thread
        # thread_harware_init = threading.Thread(name='hardware_init_small_loop', target=self.hardware_init_small_loop)
        # thread_harware_init.start()

        self.root.protocol("WM_DELETE_WINDOW", self.onQuit)

    def hardware_init_small_loop(self):
        while self.is_hardware_loaded is False:
            self.root.update()
            time.sleep(0.5)

    def run(self):
        self.root.title("pyMacGUIver")
        self.root.deiconify()
        self.root.mainloop()

    def launch_MicroManager(self):
        try:
            # self.mmc = MMCorePy.CMMCore()
            # print(self.mmc.getVersionInfo())
            # print(self.mmc.getAPIVersionInfo())
            pass
        except:
            print("Can't launch micro-manager core.\n Exiting.")
            return


    def start_splash_screen(self, hardware_selection):
        self.splash_screen = SplashScreen(self)

        # Create textLogger
        self.splash_log_text_handler = TextHandler(self.splash_screen.txt)

        # Add the handler to logger
        self.splash_logger = logging.getLogger()
        self.splash_logger.setLevel(logging.INFO)
        formatter = logging.Formatter('%(asctime)s :: %(levelname)s :: %(message)s')
        self.splash_log_text_handler.setFormatter(formatter)
        self.splash_logger.addHandler(self.splash_log_text_handler)

        time.sleep(0.5)

        self.create_hardware(hardware_selection)
        self.splash_screen.set_exit_btn_ok()
        self.is_hardware_loaded = True

        # self.createMidiControl()



        self.create_gui()
        self.launch_ctrl()
        self.close_splash_screen()
        #self.midiListener.startListening()
        #self.createMenuCommands()
        #self.createShortCut()


    def write_to_splash_screen(self, msg, type="info"):
        if self.splash_screen is None:
            return
        if type == "info":
            self.splash_logger.info(msg)
        elif type == "debug":
            self.splash_logger.debug(msg)
        elif type == "warn":
            self.splash_logger.warn(msg)
        elif type == "critical":
            self.splash_logger.critical(msg)

    def close_splash_screen(self):
        pass


    def create_hardware(self, hardware_selection):

        if hardware_selection["MCL XY"].get() == 1:
            self.madLibCity_XY  = MCL_XY.madLibCity_XY(self)
            if self.madLibCity_XY.initialized:
                self.listHardware.append(self.madLibCity_XY)
        if hardware_selection["Standa XY"].get() == 1:
            self.standa_XY = Standa_XY.Standa_XY(self)
            if self.standa_XY.initialized:
                self.listHardware.append(self.standa_XY)
        if hardware_selection["Arduino Counting"].get() == 1:
            self.countingArduino = ArduinoCounting.ArduinoCouting(self)
            if self.countingArduino.initialized:
                self.listHardware.append(self.countingArduino)
        if hardware_selection["Elveflow OB1"].get() == 1:
            self.ob1 = OB1_MK3.OB1MK3(self)
            if self.ob1.initialized:
                self.listHardware.append(self.ob1)
        if hardware_selection["Arduino Pulser"].get() == 1:
            self.arduino_pulser = ArduinoPulser.ArduinoPulser(self)
            if self.arduino_pulser.initialized:
                self.listHardware.append(self.arduino_pulser)
        if hardware_selection["FPGA Nist"].get() == 1:
            self.fpga_nist = fpga_nist.FPGA_nist(self)
            if self.fpga_nist.initialized:
                self.listHardware.append(self.fpga_nist)
        if hardware_selection["Valve Manager"].get() == 1:
            self.valveManager = valveManager.ValveManager(self)
            if self.valveManager.initialized:
                self.listHardware.append(self.valveManager)

        if hardware_selection["Thorlabs Filter Slider"]:
            pass
            # self.filter_slide = FilterSlide.FilterSlide(self)
            # if self.filter_slide.initialized:
            #     self.listHardware.append(self.filter_slide)

        if hardware_selection["XY Scanner"].get() == 1:
            if self.standa_XY.initialized and self.countingArduino.initialized:
                self.xy_scanner = xy_scanner.XYScanner(self, self.standa_XY, self.countingArduino)
                if self.xy_scanner.initialized:
                    self.listHardware.append(self.xy_scanner)
                    # self.listHardware.append(self.dummy_XY)

        if hardware_selection["Spectro (Work In progress)"].get() == 1:
            self.spectro = Spectro.Spectro(self)
            self.listHardware.append(self.spectro)

        # if hardware_selection["Fianium"].get() == 1:
        #     pass

        # if hardware_selection["midi_crtl"]:
        #     self.create_midi_control()

        if hardware_selection["Joystick control"].get() == 1:
            self.create_joystick_control()
            self.listHardware.append(self.joystick_listener)



    def create_midi_control(self):
        self.midiListener = midiControl.MidiListener(self)
        self.register_midi_callback()
        self.midiListener.createGUI()

    def create_joystick_control(self):
        self.joystick_listener = joystick.JoystickListener(self)
        self.register_joy_callback()
        self.joystick_listener.createGUI()

    def create_gui(self):
        for device in self.listHardware:
            device.frame.pack()

        # self.dummy_XYStage.frame.pack()
        # self.madLibCity_XY.frame.pack()
        # # self.standa_XY.frame.pack()
        # if self.countingArduino.initialized:
        #     self.countingArduino.frame.pack()
        # # self.spectro.createGUI()
        # self.spectro.frame.pack()

        # self.midiListener.frame.pack()

    def launch_ctrl(self):
        if self.joystick_listener is not None:
            self.joystick_listener.start_listening()

    def register_midi_callback(self):
        self.midiListener.registerCallback(type="relative", name="MCL_X", midiCC=32, callBack=[self.dummy_XYStage.move_left, self.dummy_XYStage.move_right])
        self.midiListener.registerCallback(type="relative", name="MCL_Y", midiCC=33,
                                           callBack=[self.dummy_XYStage.move_down, self.dummy_XYStage.move_up])

        self.midiListener.registerCallback(type="relative", name="MCL_StepX_small", midiCC=40, inc=1, tkVariable=self.dummy_XYStage.stepX_sv, callBack=[self.dummy_XYStage.get_GUI_params, self.dummy_XYStage.get_GUI_params])
        self.midiListener.registerCallback(type="relative", name="MCL_StepY_small", midiCC=41, inc=1,
                                           tkVariable=self.dummy_XYStage.stepY_sv, callBack=[self.dummy_XYStage.get_GUI_params, self.dummy_XYStage.get_GUI_params])

        self.midiListener.registerCallback(type="relative", name="MCL_StepX_big", midiCC=48, inc=10, tkVariable=self.dummy_XYStage.stepX_sv, callBack=[self.dummy_XYStage.get_GUI_params, self.dummy_XYStage.get_GUI_params])
        self.midiListener.registerCallback(type="relative", name="MCL_StepY_big", midiCC=49, inc=10,
                                           tkVariable=self.dummy_XYStage.stepY_sv, callBack=[self.dummy_XYStage.get_GUI_params, self.dummy_XYStage.get_GUI_params])

    def register_joy_callback(self):


        if self.madLibCity_XY is not None:
            self.joystick_listener.registerCallback(type="button", num=0, name="MCL_dblStep",
                                                    callBack=self.madLibCity_XY.double_step)
            self.joystick_listener.registerCallback(type="button", num=1, name="MCL_halfStep",
                                                    callBack=self.madLibCity_XY.halve_step)

            self.joystick_listener.registerCallback(type="axis", num=1, name="MCL_up", callBack=self.madLibCity_XY.move_right)
            self.joystick_listener.registerCallback(type="axis", num=-1, name="MCL_down", callBack=self.madLibCity_XY.move_left)
            self.joystick_listener.registerCallback(type="axis", num=2, name="MCL_left", callBack=self.madLibCity_XY.move_down)
            self.joystick_listener.registerCallback(type="axis", num=-2, name="MCL_right", callBack=self.madLibCity_XY.move_up)


    def show_microfluidics_tool_box(self):
        ToolBoxMicroFLuidics.ToolBoxMicrofluidics(self.root)

    def onQuit(self):
        # paramFile = open('param.ini', 'w')
        # paramFile.write(self.saveDir)
        self.root.destroy()
        self.root.quit()
Beispiel #15
0
        SplashScreen.sendMessage(formatText('UI初始化完成', 'white'))
        sleep(2)

        # 模拟加载其它数据
        t = Thread(target=initData, daemon=True)
        t.start()
        t.join()

        # 加载完成发送退出
        SplashScreen.sendMessage(
            json.dumps({
                'text': 'exit',
                'progress': 0
            }) + '\n')
        SplashScreen.disconnect()


if __name__ == '__main__':
    cgitb.enable(format='text')

    SplashScreen.connect(True)
    SplashScreen.sendMessage(formatText('初始化中...', 'white'))

    app = QApplication(sys.argv)

    # 创建界面
    w = Window()
    w.show()

    sys.exit(app.exec_())
Beispiel #16
0
class Installer:

	SHOW_BUTTON_FINISH = 1
	SHOW_BUTTON_FORWARD = 1
	SHOW_BUTTON_BACK = 1
	SHOW_BUTTON_HELP = 1
	SHOW_BUTTON_EXIT = 1
	install_profile_xml_file = ""
	install_window = None

	menuItems = [ { 'text': _('Welcome'), 'module': __import__("Welcome") },
                  { 'text': _('Pre-install Config'), 'module': __import__("ClientConfig") },
                  { 'text': _('Partitioning'), 'module': __import__("Partitioning") },
                  { 'text': _('Network Mounts'), 'module': __import__("NetworkMounts") },
#                  { 'text': _('Stage'), 'module': __import__("Stage") },
                  { 'text': _('Portage tree'), 'module': __import__("PortageTree") },
#                  { 'text': _('make.conf'), 'module': __import__("MakeDotConf") },
#                  { 'text': _('Kernel'), 'module': __import__("Kernel") },
                  { 'text': _('Bootloader'), 'module': __import__("Bootloader") },
                  { 'text': _('Timezone'), 'module': __import__("Timezone") },
                  { 'text': _('Networking'), 'module': __import__("Networking") },
#                  { 'text': _('Daemons'), 'module': __import__("Daemons") },
#                  { 'text': _('Extra Packages'), 'module': __import__("ExtraPackages") },
#                  { 'text': _('Startup Services'), 'module': __import__("StartupServices") },
                  { 'text': _('Other Settings'), 'module': __import__("OtherSettings") },
                  { 'text': _('Users'), 'module': __import__("Users") },
                  { 'text': _('Review'), 'module': __import__("InstallSummary") }
                ]

	def __init__(self):
		self.client_profile = GLIClientConfiguration.ClientConfiguration()
		self.install_profile = GLIInstallProfile.InstallProfile()
		self._pretend = False
		self._debug = False

		for arg in sys.argv:
			if arg == "-p" or arg == "--pretend":
				self._pretend = True
			elif arg == "-d" or arg == "--debug":
				self._debug = True

		self.cc = GLIClientController.GLIClientController(pretend=self._pretend)

		self.window = None
		self.panel = None
		self._cur_panel = 0
		self.__full_path = self.get_current_path()
		self.splash = SplashScreen(self.__full_path)
		self.splash.show()
		while gtk.events_pending():
			gtk.main_iteration()
		self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
		self.title = _("Gentoo Linux Installer")
		self.window.realize()
		self.window.connect("delete_event", self.delete_event)
		self.window.connect("destroy", self.destroy)
		self.window.set_border_width(0)
		self.window.set_default_size(800,600)
		self.window.set_geometry_hints(None, min_width=800, min_height=600, max_width=800, max_height=600)
		self.window.set_title(_("Gentoo Linux Installer"))
		self.globalbox = gtk.VBox(False, 0)
		self.window.add(self.globalbox)

		# Banner image
		self.headerbox = gtk.HBox(False, 0)
		headerimg = gtk.Image()
		headerimg.set_from_file(self.__full_path + '/installer-banner-800x64.png')
		self.headerbox.add(headerimg)
		self.globalbox.pack_start(self.headerbox, expand=False, fill=False, padding=0)

		# Future bar
		self.futurebar = GLIFutureBar([element['text'] for element in self.menuItems])
		self.globalbox.pack_start(self.futurebar, expand=False, fill=False, padding=5)
		self.globalbox.pack_start(gtk.HSeparator(), expand=False, fill=False, padding=0)

		# Top box
		self.topbox = gtk.HBox(False, 0)
		self.globalbox.pack_start(self.topbox, expand=True, fill=True, padding=5)

		# Bottom box
		self.bottombox = gtk.HBox(False, 0)
		self.globalbox.pack_end(self.bottombox, expand=False, fill=False, padding=5)
		self.globalbox.pack_end(gtk.HSeparator(), expand=False, fill=False, padding=0)
		self.rightframe = gtk.VBox(False, 0)
		self.topbox.pack_end(self.rightframe, expand=True, fill=True, padding=5)
		self.globalbox.show_all();

		# Right frame contents
		self.panels = []
		self.right_pane_box = gtk.Notebook()
#		for item in self.menuItems:
#			if item['module'] == None: break
#			if self._debug:
#				print "Instantiating " + item['text'] + " screen...",
#			panel = item['module'].Panel(self)
#			if self._debug:
#				print "done"
#			self.panels.append(panel)
#			self.right_pane_box.append_page(panel)
		self.right_pane_box.set_show_tabs(False)
		self.right_pane_box.set_show_border(False)
		self.rightframe.add(self.right_pane_box)

		buttons_info = [ ('exit', _(" _Exit "), '/button_images/stock_exit.png', self.exit_button, 'start'),
                                 ('help', _(" _Help "), '/button_images/stock_help.png', self.help, 'start'),
                                 ('load', _(" _Load "), '/button_images/stock_open.png', self.load_button, 'start'),
                                 ('save', _(" _Save "), '/button_images/stock_save.png', self.save_button, 'start'),
                                 ('finish', _(" _Install "), '/button_images/stock_exec.png', self.finish, 'end'),
                                 ('forward', _(" _Forward "), '/button_images/stock_right.png', self.forward, 'end'),
                                 ('back', _(" _Back "), '/button_images/stock_left.png', self.back, 'end')
                               ]
		self.buttons = {}

		for button in buttons_info:
			self.buttons[button[0]] = gtk.Button()
			tmpbuttonbox = gtk.HBox(False, 0)
			tmpbuttonimg = gtk.Image()
			tmpbuttonimg.set_from_file(self.__full_path + button[2])
			tmpbuttonbox.pack_start(tmpbuttonimg)
			tmpbuttonlabel = gtk.Label(button[1])
			tmpbuttonlabel.set_use_underline(True)
			tmpbuttonbox.pack_start(tmpbuttonlabel)
			self.buttons[button[0]].add(tmpbuttonbox)
			self.buttons[button[0]].connect("clicked", button[3], None)
			if button[4] == "start":
				self.bottombox.pack_start(self.buttons[button[0]], expand=False, fill=False, padding=5)
			else:
				self.bottombox.pack_end(self.buttons[button[0]], expand=False, fill=False, padding=5)

		gobject.idle_add(self.init_screens)

	def redraw_left_pane(self, firstrun=False):
		if not firstrun: self.leftframe.remove(self.navlinks)
		self.navlinks = gtk.VBox(False, 5)
		self.navlinks.set_size_request(140, -1)
		navlinkslabel = gtk.Label(_("    Installation Steps    "))
		self.navlinks.pack_start( navlinkslabel, expand=False, fill=False, padding=10)
		self.num_times = 0
		for item_ in self.menuItems:
			item = str(self.num_times+1) + ". " + item_['text']
			self.box = gtk.HBox(False,5)
			box_string = item
			box_label=gtk.Label(box_string)
			box_label.set_alignment(0,0)
			self.box.pack_start( box_label, expand=False, fill=False, padding=5)
			self.navlinks.pack_start( self.box, expand=False, fill=False, padding=3)
			box_label.set_sensitive(True)

			if self._cur_panel == self.num_times:
				box_label.set_markup('<b>'+box_string+'</b>')

			self.num_times = self.num_times + 1
		self.leftframe.add(self.navlinks)
		self.leftframe.show_all()

	def redraw_buttons(self):
		self.bottombox.hide_all()
		self.buttons['finish'].set_sensitive(self.SHOW_BUTTON_FINISH)
		self.buttons['forward'].set_sensitive(self.SHOW_BUTTON_FORWARD)
		self.buttons['back'].set_sensitive(self.SHOW_BUTTON_BACK)
		self.buttons['help'].set_sensitive(self.SHOW_BUTTON_HELP)
		self.buttons['exit'].set_sensitive(self.SHOW_BUTTON_EXIT)
		if self.SHOW_BUTTON_FORWARD:
			self.buttons['forward'].set_flags(gtk.CAN_DEFAULT)
			self.buttons['forward'].grab_default()
		elif self.SHOW_BUTTON_FINISH:
			self.buttons['finish'].set_flags(gtk.CAN_DEFAULT)
			self.buttons['finish'].grab_default()
#		if self.install_profile_xml_file != "":
#			self.finishbutton.set_sensitive(True)
		self.bottombox.show_all()

	def refresh_right_panel(self):
		self.rightframe.show_all()

	def make_visible(self):
		self.window.show_all()
		self.window.present()

	def make_invisible(self):
		self.window.hide_all()

	def get_current_path(self):
		# this will return the absolute path to the
		# directory containing this file
		# it will only work if this file is imported somewhere,
		# not if it is run directly (__file__ will be undefined)
		import os.path
		return os.path.abspath(os.path.dirname(__file__))

	def add_content(self, content):
		self.right_pane_box.pack_end(content, True, True, 0)

	def get_commands(self):
		pass

	def set_active(self):
		self.active=1

	def loadPanel(self, panel=0):
		if not self.panels[self._cur_panel].deactivate():
			return
		self._cur_panel = panel
		self.right_pane_box.set_current_page(panel)
		self.panels[panel].activate()
		self.futurebar.setpos(panel)
		self.redraw_buttons()

	def init_screens(self):
#		self.splash.show()
		for item in self.menuItems:
			if item['module'] == None: break
			if self._debug:
				print "Instantiating " + item['text'] + " screen...",
			panel = item['module'].Panel(self)
			if self._debug:
				print "done"
			self.panels.append(panel)
			self.right_pane_box.append_page(panel)
		self.splash.destroy()
		self.make_visible()
		self.loadPanel()
		return False

	def run(self):
		gtk.threads_init()
		gtk.main()

	def back(self, widget, data=None):
		if self._cur_panel > 0:
			self.loadPanel(self._cur_panel - 1)

	def forward(self, widget, data=None):
		if self._cur_panel < (len(self.menuItems) - 1):
			self.loadPanel(self._cur_panel + 1)

	def help(self, widget, data=None):
#		GLIUtility.spawn("firefox http://www.gentoo.org/doc/en/handbook/index.xml &>/dev/null &")
		try:
			helptext = self.panels[self._cur_panel]._helptext
		except:
			helptext = "There is no help available for this screen"
		helpdlg = HelpDialog(self.window, helptext)
		helpdlg.run()

	def exit_button(self, widget, data=None):
		msgdlg = gtk.MessageDialog(parent=self.window, type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_YES_NO, message_format="Are you sure you want to exit?")
		resp = msgdlg.run()
		msgdlg.destroy()
		if resp == gtk.RESPONSE_YES:
			self.exit()

	def finish(self, widget, data=None):
		# Remove screens
		while len(self.panels):
			self.right_pane_box.remove_page(-1)
			del self.panels[-1]
		self.make_invisible()
		self.install_window = RunInstall.RunInstall(self)

	def load_button(self, widget, data=None):
		filesel = gtk.FileSelection(_("Select the install profile to load"))
		if self.install_profile_xml_file == "":
			filesel.set_filename("installprofile.xml")
		else:
			filesel.set_filename(self.install_profile_xml_file)
		resp = filesel.run()
		filename = filesel.get_filename()
		filesel.destroy()
		if resp == gtk.RESPONSE_OK:
			self.install_profile_xml_file = filename
			try:
				tmp_install_profile = GLIInstallProfile.InstallProfile()
				tmp_install_profile.parse(self.install_profile_xml_file)
				self.install_profile = tmp_install_profile
				msgdlg = gtk.MessageDialog(parent=self.window, type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_OK, message_format=_("Install profile loaded successfully!"))
				msgdlg.run()
				msgdlg.destroy()
			except:
				errdlg = gtk.MessageDialog(parent=self.window, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK, message_format=_("An error occured loading the install profile"))
				errdlg.run()
				errdlg.destroy()

	def save_button(self, widget, data=None):
		filesel = gtk.FileSelection(_("Select the location to save the install profile"))
		if self.install_profile_xml_file == "":
			filesel.set_filename("installprofile.xml")
		else:
			filesel.set_filename(self.install_profile_xml_file)
		resp = filesel.run()
		filename = filesel.get_filename()
		filesel.destroy()
		if resp == gtk.RESPONSE_OK:
			self.install_profile_xml_file = filename
			try:
				configuration = open(filename, "w")
				configuration.write(self.install_profile.serialize())
				configuration.close()
				msgdlg = gtk.MessageDialog(parent=self.window, type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_OK, message_format=_("Install profile saved successfully!"))
				msgdlg.run()
				msgdlg.destroy()
			except:
				errdlg = gtk.MessageDialog(parent=self.window, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK, message_format=_("An error occured saving the install profile"))
				errdlg.run()
				errdlg.destroy()

	def delete_event(self, widget, event, data=None):
		return False

	def destroy(self, widget, data=None):
		gtk.main_quit()
		return True
	
	def exit(self):
		gtk.main_quit()
		sys.exit(0)
Beispiel #17
0
	def __init__(self):
		self.client_profile = GLIClientConfiguration.ClientConfiguration()
		self.install_profile = GLIInstallProfile.InstallProfile()
		self._pretend = False
		self._debug = False

		for arg in sys.argv:
			if arg == "-p" or arg == "--pretend":
				self._pretend = True
			elif arg == "-d" or arg == "--debug":
				self._debug = True

		self.cc = GLIClientController.GLIClientController(pretend=self._pretend)

		self.window = None
		self.panel = None
		self._cur_panel = 0
		self.__full_path = self.get_current_path()
		self.splash = SplashScreen(self.__full_path)
		self.splash.show()
		while gtk.events_pending():
			gtk.main_iteration()
		self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
		self.title = _("Gentoo Linux Installer")
		self.window.realize()
		self.window.connect("delete_event", self.delete_event)
		self.window.connect("destroy", self.destroy)
		self.window.set_border_width(0)
		self.window.set_default_size(800,600)
		self.window.set_geometry_hints(None, min_width=800, min_height=600, max_width=800, max_height=600)
		self.window.set_title(_("Gentoo Linux Installer"))
		self.globalbox = gtk.VBox(False, 0)
		self.window.add(self.globalbox)

		# Banner image
		self.headerbox = gtk.HBox(False, 0)
		headerimg = gtk.Image()
		headerimg.set_from_file(self.__full_path + '/installer-banner-800x64.png')
		self.headerbox.add(headerimg)
		self.globalbox.pack_start(self.headerbox, expand=False, fill=False, padding=0)

		# Future bar
		self.futurebar = GLIFutureBar([element['text'] for element in self.menuItems])
		self.globalbox.pack_start(self.futurebar, expand=False, fill=False, padding=5)
		self.globalbox.pack_start(gtk.HSeparator(), expand=False, fill=False, padding=0)

		# Top box
		self.topbox = gtk.HBox(False, 0)
		self.globalbox.pack_start(self.topbox, expand=True, fill=True, padding=5)

		# Bottom box
		self.bottombox = gtk.HBox(False, 0)
		self.globalbox.pack_end(self.bottombox, expand=False, fill=False, padding=5)
		self.globalbox.pack_end(gtk.HSeparator(), expand=False, fill=False, padding=0)
		self.rightframe = gtk.VBox(False, 0)
		self.topbox.pack_end(self.rightframe, expand=True, fill=True, padding=5)
		self.globalbox.show_all();

		# Right frame contents
		self.panels = []
		self.right_pane_box = gtk.Notebook()
#		for item in self.menuItems:
#			if item['module'] == None: break
#			if self._debug:
#				print "Instantiating " + item['text'] + " screen...",
#			panel = item['module'].Panel(self)
#			if self._debug:
#				print "done"
#			self.panels.append(panel)
#			self.right_pane_box.append_page(panel)
		self.right_pane_box.set_show_tabs(False)
		self.right_pane_box.set_show_border(False)
		self.rightframe.add(self.right_pane_box)

		buttons_info = [ ('exit', _(" _Exit "), '/button_images/stock_exit.png', self.exit_button, 'start'),
                                 ('help', _(" _Help "), '/button_images/stock_help.png', self.help, 'start'),
                                 ('load', _(" _Load "), '/button_images/stock_open.png', self.load_button, 'start'),
                                 ('save', _(" _Save "), '/button_images/stock_save.png', self.save_button, 'start'),
                                 ('finish', _(" _Install "), '/button_images/stock_exec.png', self.finish, 'end'),
                                 ('forward', _(" _Forward "), '/button_images/stock_right.png', self.forward, 'end'),
                                 ('back', _(" _Back "), '/button_images/stock_left.png', self.back, 'end')
                               ]
		self.buttons = {}

		for button in buttons_info:
			self.buttons[button[0]] = gtk.Button()
			tmpbuttonbox = gtk.HBox(False, 0)
			tmpbuttonimg = gtk.Image()
			tmpbuttonimg.set_from_file(self.__full_path + button[2])
			tmpbuttonbox.pack_start(tmpbuttonimg)
			tmpbuttonlabel = gtk.Label(button[1])
			tmpbuttonlabel.set_use_underline(True)
			tmpbuttonbox.pack_start(tmpbuttonlabel)
			self.buttons[button[0]].add(tmpbuttonbox)
			self.buttons[button[0]].connect("clicked", button[3], None)
			if button[4] == "start":
				self.bottombox.pack_start(self.buttons[button[0]], expand=False, fill=False, padding=5)
			else:
				self.bottombox.pack_end(self.buttons[button[0]], expand=False, fill=False, padding=5)

		gobject.idle_add(self.init_screens)
Beispiel #18
0
import pygame
pygame.init()
pygame.display.set_mode()
from ObjectHandler import ObjectHandler
from SplashScreen import SplashScreen

Splash = SplashScreen().setupScreen()

if __name__ == '__main__':

    objectHandler = ObjectHandler()
    objectHandler.run()
    pygame.quit()
from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import QWidget

import Resource_rc
from SplashScreen import SplashScreen
from UiFiles.Ui_AdobeCenter import Ui_AdobeCenter


class AdobeCenter(QWidget, Ui_AdobeCenter):
    def __init__(self):
        super(AdobeCenter, self).__init__()
        self.setupUi(self)


if __name__ == '__main__':
    cgitb.enable(format='text')
    Resource_rc.qInitResources()

    executable = 'Client'
    if sys.argv[0].find('.py') > -1:
        # 调试时用
        sys.argv.append(os.path.abspath('Client.py'))
        executable = sys.executable

    SplashScreen.start(executable,
                       ':/Resources/Splash2013Background.png',
                       AdobeCenter,
                       above=True,
                       color=QColor(43, 204, 249))
Beispiel #20
0
    def __init__(self):
        self.client_profile = GLIClientConfiguration.ClientConfiguration()
        self.install_profile = GLIInstallProfile.InstallProfile()
        self._pretend = False
        self._debug = False

        for arg in sys.argv:
            if arg == "-p" or arg == "--pretend":
                self._pretend = True
            elif arg == "-d" or arg == "--debug":
                self._debug = True

        self.cc = GLIClientController.GLIClientController(
            pretend=self._pretend)

        self.window = None
        self.panel = None
        self._cur_panel = 0
        self.__full_path = self.get_current_path()
        self.splash = SplashScreen(self.__full_path)
        self.splash.show()
        while gtk.events_pending():
            gtk.main_iteration()
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.title = _("Gentoo Linux Installer")
        self.window.realize()
        self.window.connect("delete_event", self.delete_event)
        self.window.connect("destroy", self.destroy)
        self.window.set_border_width(0)
        self.window.set_default_size(800, 600)
        self.window.set_geometry_hints(None,
                                       min_width=800,
                                       min_height=600,
                                       max_width=800,
                                       max_height=600)
        self.window.set_title(_("Gentoo Linux Installer"))
        self.globalbox = gtk.VBox(False, 0)
        self.window.add(self.globalbox)

        # Banner image
        self.headerbox = gtk.HBox(False, 0)
        headerimg = gtk.Image()
        headerimg.set_from_file(self.__full_path +
                                '/installer-banner-800x64.png')
        self.headerbox.add(headerimg)
        self.globalbox.pack_start(self.headerbox,
                                  expand=False,
                                  fill=False,
                                  padding=0)

        # Future bar
        self.futurebar = GLIFutureBar(
            [element['text'] for element in self.menuItems])
        self.globalbox.pack_start(self.futurebar,
                                  expand=False,
                                  fill=False,
                                  padding=5)
        self.globalbox.pack_start(gtk.HSeparator(),
                                  expand=False,
                                  fill=False,
                                  padding=0)

        # Top box
        self.topbox = gtk.HBox(False, 0)
        self.globalbox.pack_start(self.topbox,
                                  expand=True,
                                  fill=True,
                                  padding=5)

        # Bottom box
        self.bottombox = gtk.HBox(False, 0)
        self.globalbox.pack_end(self.bottombox,
                                expand=False,
                                fill=False,
                                padding=5)
        self.globalbox.pack_end(gtk.HSeparator(),
                                expand=False,
                                fill=False,
                                padding=0)
        self.rightframe = gtk.VBox(False, 0)
        self.topbox.pack_end(self.rightframe,
                             expand=True,
                             fill=True,
                             padding=5)
        self.globalbox.show_all()

        # Right frame contents
        self.panels = []
        self.right_pane_box = gtk.Notebook()
        #		for item in self.menuItems:
        #			if item['module'] == None: break
        #			if self._debug:
        #				print "Instantiating " + item['text'] + " screen...",
        #			panel = item['module'].Panel(self)
        #			if self._debug:
        #				print "done"
        #			self.panels.append(panel)
        #			self.right_pane_box.append_page(panel)
        self.right_pane_box.set_show_tabs(False)
        self.right_pane_box.set_show_border(False)
        self.rightframe.add(self.right_pane_box)

        buttons_info = [
            ('exit', _(" _Exit "), '/button_images/stock_exit.png',
             self.exit_button, 'start'),
            ('help', _(" _Help "), '/button_images/stock_help.png', self.help,
             'start'),
            ('load', _(" _Load "), '/button_images/stock_open.png',
             self.load_button, 'start'),
            ('save', _(" _Save "), '/button_images/stock_save.png',
             self.save_button, 'start'),
            ('finish', _(" _Install "), '/button_images/stock_exec.png',
             self.finish, 'end'),
            ('forward', _(" _Forward "), '/button_images/stock_right.png',
             self.forward, 'end'),
            ('back', _(" _Back "), '/button_images/stock_left.png', self.back,
             'end')
        ]
        self.buttons = {}

        for button in buttons_info:
            self.buttons[button[0]] = gtk.Button()
            tmpbuttonbox = gtk.HBox(False, 0)
            tmpbuttonimg = gtk.Image()
            tmpbuttonimg.set_from_file(self.__full_path + button[2])
            tmpbuttonbox.pack_start(tmpbuttonimg)
            tmpbuttonlabel = gtk.Label(button[1])
            tmpbuttonlabel.set_use_underline(True)
            tmpbuttonbox.pack_start(tmpbuttonlabel)
            self.buttons[button[0]].add(tmpbuttonbox)
            self.buttons[button[0]].connect("clicked", button[3], None)
            if button[4] == "start":
                self.bottombox.pack_start(self.buttons[button[0]],
                                          expand=False,
                                          fill=False,
                                          padding=5)
            else:
                self.bottombox.pack_end(self.buttons[button[0]],
                                        expand=False,
                                        fill=False,
                                        padding=5)

        gobject.idle_add(self.init_screens)
# create formatter and add it to the handlers
formatter = logging.Formatter(
    '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
# add the handlers to the logger
logger.addHandler(fh)

# --- This is the logger for CLI, we do not need it for now.
# ch.setFormatter(formatter)
# logger.addHandler(ch)
# ---

logger.info("Turtle Wallet Started")
signal.signal(
    signal.SIGINT,
    signal.SIG_DFL)  # Required to handle interrupts closing the program
logger.info("Starting Splash Screen")
splash_screen = SplashScreen(
    args.wallet)  # Create a new instance of the splash screen

# Make sure the splash screen wasn't cancelled by the user
if not splash_screen.startup_cancelled:
    Gtk.main()  # Start the main GTK loop
else:
    logger.info("Tutle Wallet exiting")

if global_variables.wallet_connection:
    logger.info("Stopping wallet daemon")
    global_variables.wallet_connection.stop_wallet_daemon()