示例#1
0
class FormLain(QWidget):
    def __init__(self):
        super().__init__()
        self.setupUi()

    def setupUi(self):
        self.resize(400, 300)
        self.move(300, 300)
        self.setWindowTitle('Form Lain')

        self.button = QPushButton('About')
        self.button1 = QPushButton('Tutup')
        self.button.move(150, 130)
        self.button1.move(310, 260)
        self.button.setParent(self)
        self.button1.setParent(self)

        self.button.clicked.connect(self.buttonClick)
        self.button1.clicked.connect(self.buttonClick1)

    def buttonClick(self):
        self.form = About()
        self.form.show()

    def buttonClick1(self):
        self.close()
示例#2
0
def go_play():
    Menu.drow()
    while tests:
        if Menu.check == 1:
            start_game()
            Test.drow(scores)
        if Menu.check == 2:
            About.run = True
            About.drow()
        if About.flag:
            Menu.running = True
            Menu.drow()
示例#3
0
文件: Crony.py 项目: pronoyroy/Crony
 def open_about(self):
     import About
     aboutDialog = QtGui.QDialog()
     aboutUi = About.Ui_About()
     aboutUi.setupUi(aboutDialog)
     aboutDialog.show()
     self.windows.append(aboutDialog)  #list of open windows
示例#4
0
    def _aboutDialog(self):
        if self._about != 0:
            return
        self._about = About.About(self._master, self._onAboutClose)

        # Disable resize of splash screen.
        self._about.resizable(height=0, width=0)
示例#5
0
def Nav_About(self):
    if Modules.Check.about != 'open':
        if Modules.Check.BUSY == False:
            Modules.Check.about = 'open'
            About.Create()
        else:
            Modules.Check.BusyAlert(self)
    else:
        Modules.Check.InstanceAlert(self)
示例#6
0
    def __init__(self, parent, controller):

        tk.Frame.__init__(self, parent)

        titulo = tk.Label(self, text='Portfolio Manager', font=fontTitulo)
        titulo.place(x=150, y=20, width=340)

        img = tk.PhotoImage(file='about.png')
        about = tk.Button(self,
                          image=img,
                          command=lambda: ab.About().winAbout())
        about.image = img
        about.place(x=560, y=20, width=70, height=70)

        tk.Label(self, text='Selecione o tipo',
                 font=fontCampos).place(x=250, y=170, width=140)
        tipoPort = tk.ttk.Combobox(
            self,
            text='Tipo',
            state='readonly',
            values=['Causa Raiz', 'Melhoria', 'Projeto'])
        tipoPort.place(x=260, y=200, width=120)

        LoadInfos = li.LoadInfos()
        valoresSetup = LoadInfos.loadXML('projeto', 'caracteristicas')

        tk.Label(self, text='Selecione a área',
                 font=fontCampos).place(x=250, y=230, width=140)
        areaPort = tk.ttk.Combobox(self,
                                   text='Área',
                                   state='readonly',
                                   values=valoresSetup['areas'])
        areaPort.place(x=260, y=260, width=120)

        consultPort = ttk.Button(
            self,
            text='Iniciar',
            command=lambda: validInfosPort(areaPort, tipoPort, tela)).place(
                x=280, y=290)

        def validInfosPort(area, tipo, tela):
            ## VALIDAÇÕES ##
            if len(tipo.get()) < 2:
                messagebox.showwarning('Tipo inválido',
                                       'Informe o Tipo de Portfolio')
                tk.BaseWidget.focus_force(tipo)
            elif len(area.get()) < 2:
                messagebox.showwarning('Área inválida',
                                       'Informe a Área do Portfolio')
                tk.BaseWidget.focus_force(area)
            else:
                controller.show_frame(busc_port)
                criarMenu = mc.MenuPort(tipo.get().replace(' ', ''),
                                        area.get(), tela)
                criarMenu.listaPort()
                criarMenu.atualizaPort()
    def __init__(self, Main, parent=None):
        super(BrowserTab, self).__init__(parent)
        self.mainWindow = Main
        self.AboutDialog = About.AboutDialog()
        self.browser = BrowserEngineView(self.mainWindow)
        self.browser.load(QUrl(""))
        self.setCentralWidget(self.browser)
        self.navigation_bar = QToolBar('Navigation')
        self.navigation_bar.setIconSize(QSize(32, 32))
        self.navigation_bar.setMovable(False)
        self.addToolBar(self.navigation_bar)
        self.status_bar = QStatusBar()
        self.setStatusBar(self.status_bar)

        self.back_button = QAction(QIcon('Assets/back.png'), '后退', self)
        self.next_button = QAction(QIcon('Assets/forward.png'), '前进', self)
        self.stop_button = QAction(QIcon('Assets/stop.png'), '停止', self)
        self.refresh_button = QAction(QIcon('Assets/refresh.png'), '刷新', self)
        self.home_button = QAction(QIcon('Assets/home.png'), '主页', self)
        self.enter_button = QAction(QIcon('Assets/enter.png'), '转到', self)
        self.add_button = QAction(QIcon('Assets/new.png'), '新建标签页', self)
        self.ssl_label1 = QLabel(self)
        self.ssl_label2 = QLabel(self)
        self.url_text_bar = QLineEdit(self)
        self.url_text_bar.setMinimumWidth(300)
        self.progress_bar = QProgressBar()
        self.progress_bar.setMaximumWidth(120)
        self.set_button = QAction(QIcon('Assets/setting.png'), '设置', self)
        self.navigation_bar.addAction(self.back_button)
        self.navigation_bar.addAction(self.next_button)
        self.navigation_bar.addAction(self.stop_button)
        self.navigation_bar.addAction(self.refresh_button)
        self.navigation_bar.addAction(self.home_button)
        self.navigation_bar.addAction(self.add_button)
        self.navigation_bar.addSeparator()
        self.navigation_bar.addWidget(self.ssl_label1)
        self.navigation_bar.addWidget(self.ssl_label2)
        self.navigation_bar.addWidget(self.url_text_bar)
        self.navigation_bar.addAction(self.enter_button)
        self.navigation_bar.addSeparator()
        self.navigation_bar.addWidget(self.progress_bar)
        self.navigation_bar.addAction(self.set_button)
        self.status_icon = QLabel()
        self.status_icon.setScaledContents(True)
        self.status_icon.setMaximumHeight(24)
        self.status_icon.setMaximumWidth(24)
        self.status_icon.setPixmap(QPixmap("Assets/main.png"))
        self.status_label = QLabel()
        self.status_label.setText(" 基于 PyQt5 以及 QWebEngineView 的网页浏览器 - " +
                                  self.mainWindow.version)
        self.status_bar.addWidget(self.status_icon)
        self.status_bar.addWidget(self.status_label)
示例#8
0
    def InitMenu(self):
        menuBar = wx.MenuBar()
        self.SetMenuBar(menuBar)

        File = wx.Menu()
        File.Append(101, "&Close")
        menuBar.Append(File, "&File")

        About = wx.Menu()
        About.Append(201, "&About")
        menuBar.Append(About, "&About")

        self.Bind(wx.EVT_MENU, self.OnClose, id=101)
        self.Bind(wx.EVT_MENU, self.OnAbout, id=201)
示例#9
0
    def __init__(self):
        self.sepwin = []
        super().__init__()
        self.setupUi(self)
        self.setWindowIcon(QIcon('.computerhousekeeper\\img\\more.jpg'))

        self.about = About()

        self.qsl = QStackedLayout(self.frame_content)
        self.qsl.addWidget(self.about)

        self.pushButton_about.clicked.connect(self.show_panel)
        self.pushButton_about.customContextMenuRequested.connect(
            self.pushButton_about_showrightmenu)

        logging.info(f'初始化{type(self).__name__}窗口')
示例#10
0
 def trigger(self, sCmd):
     try:
         if sCmd == "About":
             import About
             xDialog = About.AboutGrammalecte(self.ctx)
             xDialog.run(self.sLang)
         elif sCmd.startswith("CJ"):
             import Conjugueur
             xDialog = Conjugueur.Conjugueur(self.ctx)
             if sCmd[2:3] == "/":
                 xDialog.run(sCmd[3:])
             else:
                 xDialog.run()
         elif sCmd == "TF":
             import TextFormatter
             xDialog = TextFormatter.TextFormatter(self.ctx)
             xDialog.run(self.sLang)
         elif sCmd == "DS":
             import DictionarySwitcher
             xDialog = DictionarySwitcher.FrenchDictionarySwitcher(self.ctx)
             xDialog.run(self.sLang)
         elif sCmd == "MA":
             import Author
             xDialog = Author.Author(self.ctx)
             xDialog.run(self.sLang)
         elif sCmd == "OP":
             import Options
             xDialog = Options.GC_Options(self.ctx)
             xDialog.run(self.sLang)
         elif sCmd.startswith("FA/"):
             findAll(sCmd[6:], (sCmd[3:4] == "y"), (sCmd[4:5] == "y"))
         # elif sCmd.startswith("URL/"):
         #     # Call from context menu to launch URL?
         #     # http://opengrok.libreoffice.org/xref/core/sw/source/ui/lingu/olmenu.cxx#785
         #     xSystemShellExecute = self.ctx.getServiceManager().createInstanceWithContext('com.sun.star.system.SystemShellExecute', self.ctx)
         #     xSystemShellExecute.execute(url, "", uno.getConstantByName("com.sun.star.system.SystemShellExecuteFlags.URIS_ONLY"))
         elif sCmd == "None":
             pass
         else:
             print("Unknown command: " + str(sCmd))
     except:
         traceback.print_exc()
示例#11
0
    def LoadCurrentScreen(self, setScreen, state=0):

        if (self.currentScreen is not None):
            print("New Screen")
            self.currentScreen.KillAll()
            self.currentScreen = None

        if (setScreen == "Print"):
            self.currentScreen = Printing.PrintScreen(
                self.screen, self.printingScreenLoader, self.beeCon, state)
        else:
            if setScreen == "PrinterInfo":
                self.currentScreen = PrinterInfo.PrinterInfoScreen(
                    self.screen, self.printerInfoScreenLoader, self.beeCon)
            elif setScreen == "Jog":
                self.currentScreen = Jog.JogScreen(self.screen, self.jogLoader,
                                                   self.beeCon)
            elif setScreen == "Calibration":
                self.currentScreen = Calibration.CalibrationScreen(
                    self.screen, self.calibrationLoader, self.beeCon)
            elif setScreen == "FilamentChange":
                self.currentScreen = FilamentChange.FilamentChangeScreen(
                    self.screen, self.filamentChangeLoader, self.beeCon)
            elif setScreen == "Settings":
                self.currentScreen = Settings.SettingsScreen(
                    self.screen, self.settingsLoader, self.beeCon)
            elif setScreen == "FileBrowser":
                self.currentScreen = FileBrowser.FileBrowserScreen(
                    self.screen, self.fileBrowserLoader, self.beeCon)
            elif setScreen == "About":
                self.currentScreen = About.AboutScreen(self.screen,
                                                       self.aboutLoader,
                                                       self.beeCon)

            self.currentScreenName = self.currentScreen.GetCurrentScreenName()

        return
示例#12
0
def mainloop():

    # mainloop
    run = True
    while run:
        pygame.display.update()
        screen.fill(pygame.Color(75, 193, 114))
        events = pygame.event.get()

        for event in events:
            if event.type == pygame.QUIT:
                run = False

        if Setup.state == 0:
            Login.Login(event, events)
        if Setup.state == 2:
            mainMenu.mainMenu(event, events)
        if Setup.state == 3:
            ChooseClass.chooseClass(event, events)
        if Setup.state == 4:
            Setup.check_mainGame = runTurtle.runGame(Setup.user_character,
                                                     Setup.user_characterIndex)
            Setup.state = 5
        if Setup.state == 5:
            if Setup.check_mainGame:
                endGame.end_WIN(Setup.user_character,
                                Setup.user_characterIndex, event)
            else:
                endGame.end_Lose(Setup.user_character,
                                 Setup.user_characterIndex, event)
        if Setup.state == 6:
            Instruction.introduction(event)
        if Setup.state == 9:
            Settings.settings(event)
        if Setup.state == 10:
            About.About(event, events)
示例#13
0
def do_about():
    About.create_About_GUI(root)
示例#14
0
class SiftFlow(QtGui.QMainWindow):
    def __init__(self, parent=None):
        #If we were opened from the base sift (not the gui) setup the app internaly
        if (parent == None):
            self.app = QtGui.QApplication(sys.argv)
            self.app.setOrganizationName("Hewlett-Packard")
            self.app.setOrganizationDomain("hp.com")
            self.app.setApplicationName("SiftFlow")

            if (sys.platform.startswith("darwin")):
                self.app.setStyle("Cleanlooks")

        #Setup the window
        QtGui.QMainWindow.__init__(self)
        self.parent = parent

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        #Declare interface object with backend
        self.libMgr = SFLibManager(self, self.ui)

        #Do additional Window setup
        self.__initMainWindow()

        #Only want one reference window at a time
        self.refWin = None
        self.aboutWin = None
        self.findWin = None
        self.repWin = None

        #Set up actions and signals
        QtCore.QObject.connect(self.ui.actionAbout,
                               QtCore.SIGNAL("triggered()"), self.__about)
        QtCore.QObject.connect(self.ui.actionFind,
                               QtCore.SIGNAL("triggered()"), self.__find)
        QtCore.QObject.connect(self.ui.actionFindInFiles,
                               QtCore.SIGNAL("triggered()"),
                               self.__findInFiles)
        QtCore.QObject.connect(self.ui.actionReference,
                               QtCore.SIGNAL("triggered()"), self.reference)
        QtCore.QObject.connect(self.ui.actionReferenceInFiles,
                               QtCore.SIGNAL("triggered()"),
                               self.referenceInFiles)
        QtCore.QObject.connect(self.ui.actionCut, QtCore.SIGNAL("triggered()"),
                               self.__cut)
        QtCore.QObject.connect(self.ui.actionCopy,
                               QtCore.SIGNAL("triggered()"), self.__copy)
        QtCore.QObject.connect(self.ui.actionUndo,
                               QtCore.SIGNAL("triggered()"), self.__undo)
        QtCore.QObject.connect(self.ui.actionRedo,
                               QtCore.SIGNAL("triggered()"), self.__redo)
        QtCore.QObject.connect(self.ui.actionGoto,
                               QtCore.SIGNAL("triggered()"), self.__goto)
        QtCore.QObject.connect(self.ui.actionIndent,
                               QtCore.SIGNAL("triggered()"), self.__indent)
        QtCore.QObject.connect(self.ui.actionUnindent,
                               QtCore.SIGNAL("triggered()"), self.__unindent)
        QtCore.QObject.connect(self.ui.actionComment,
                               QtCore.SIGNAL("triggered()"), self.__comment)
        QtCore.QObject.connect(self.ui.actionUncomment,
                               QtCore.SIGNAL("triggered()"), self.__uncomment)
        QtCore.QObject.connect(self.ui.actionPaste,
                               QtCore.SIGNAL("triggered()"), self.__paste)
        QtCore.QObject.connect(self.ui.actionDownload,
                               QtCore.SIGNAL("triggered()"), self.__download)

        QtCore.QObject.connect(self.ui.treeWidget_proj,
                               QtCore.SIGNAL("itemSelectionChanged()"),
                               self.__projSelectionChanged)
        QtCore.QObject.connect(self.ui.treeWidget_nonProj,
                               QtCore.SIGNAL("itemSelectionChanged()"),
                               self.__nonProjSelectionChanged)
        QtCore.QObject.connect(self.ui.splitter_leftright,
                               QtCore.SIGNAL("splitterMoved(int, int)"),
                               self.__resizeAll)

        #QtCore.QObject.connect(self.ui.actionNewFlow, QtCore.SIGNAL("triggered()"), self.__newFlow)
        QtCore.QObject.connect(self.ui.actionOpen,
                               QtCore.SIGNAL("triggered()"), self.__open)
        QtCore.QObject.connect(self.ui.actionSave,
                               QtCore.SIGNAL("triggered()"), self.__save)
        #QtCore.QObject.connect(self.ui.actionSave_All, QtCore.SIGNAL("triggered()"), self.__saveAll)
        QtCore.QObject.connect(self.ui.menuRecent,
                               QtCore.SIGNAL("aboutToShow()"),
                               self.__fillMenuRecent)
        QtCore.QObject.connect(self.ui.menuBuild,
                               QtCore.SIGNAL("aboutToShow()"),
                               self.__fillMenuBuild)

        #SiftFlow, show thyself!!
        if (parent == None): self.show()

    def run(self):
        """Run the main QT event loop"""
        self.app.exec_()

    #--- Child Windows ---#
    def __about(self):
        if (self.aboutWin == None or self.aboutWin.isHidden()):
            self.aboutWin = About(self, self.libMgr)
            self.aboutWin.exec_()

    def __find(self):
        if (self.findWin == None or self.findWin.isHidden()):
            self.findWin = Find(self, self.libMgr)
            self.findWin.show()

    def reference(self, text='none', flags=None, isCurrent=True):
        if (self.refWin == None or not self.refWin.isVisible()):
            self.refWin = Reference(self, self.libMgr)
            result = self.refWin.addSearch(text, flags, isCurrent)
            if (isinstance(result, str) and result == 'noselection'):
                QtGui.QMessageBox.about(self, "Selection Status",
                                        "There is no text selected.")
            elif (result):
                self.refWin.show()
            else:
                QtGui.QMessageBox.about(self, "Match Status",
                                        "There are no more matches.")
        elif (self.refWin.isVisible()):  #the window is open, reset
            if (not self.refWin.addSearch(text, flags, isCurrent)):
                QtGui.QMessageBox.about(self, "Match Status",
                                        "There are no more matches.")

    def referenceInFiles(self):
        self.reference(isCurrent='all')

    #--- Signal Handlers ---#
    def __projSelectionChanged(self):
        self.libMgr.tvProjUpdate()

    def __nonProjSelectionChanged(self):
        self.libMgr.tvNonProjUpdate()

    def __cut(self):
        self.libMgr.cut()

    def __copy(self):
        self.libMgr.copy()

    def __paste(self):
        self.libMgr.paste()

    def __findInFiles(self):
        findWin = Find(self, self.libMgr)
        findWin.findInFiles()
        findWin.exec_()

    def __undo(self):
        self.libMgr.undo()

    def __redo(self):
        self.libMgr.redo()

    def __goto(self):
        lineNum, ok = QtGui.QInputDialog.getText(self, 'Go to..',
                                                 'Go To Line: ')
        if ok:
            self.libMgr.setCursorToReference(int(lineNum) - 1, 0)

    def __indent(self):
        self.libMgr.indent()

    def __unindent(self):
        self.libMgr.unindent()

    def __comment(self):
        self.libMgr.comment()

    def __uncomment(self):
        self.libMgr.uncomment()

    def __newFlow(self):
        print 'new flow'

    def __save(self):
        result = self.libMgr.saveCurrentTab()

        #Reset the reference window if it is open, to reflect any changes in the files after saving
        if (self.refWin and self.refWin.isVisible()):  #the window is open
            self.refWin.resetTabs()

    #def __saveAll(self):
    #For now I am removing save all from the ui, but will leave the functionality in.
    #Save All would rarely be used and caused a few hard to solve cunundrums with file conflicts
    #when a user had unsaved changes in both fmls and flows from those fmls. If in the future, this
    #feature is demanded, then all that needs to be done is to reattach the action to the toolbar and
    #uncomment this function, the signal and file menu entry near the bottom of this file

    #result = self.libMgr.saveAllTabs()

    #Reset the reference window if it is open, to reflect any changes in the files after saving
    #if(self.refWin and self.refWin.isVisible()): #the window is open
    #self.refWin.resetTabs()

    def __download(self):
        #Cannot download if there is no project loaded
        if (not self.libMgr.isProjLoaded()):
            self.libMgr.printError("Download failed!", 10)
            QtGui.QMessageBox.about(self, "Download Failed",
                                    "No Project Loaded.")
            return

        #Get a list of all files changed since .all was build
        dList = self.libMgr.getDownloadFileList()

        #If files have changed since the .all was built, download them to printer
        if (len(dList) > 0):
            #Turn that list into the command string
            cmd = "download " + " ".join(dList)

            #Send command to sift
            self.parent.parse(cmd)

        #If no files have changed, tell user and do nothing
        else:
            self.libMgr.out("No changed files to download", 6)

    #--- Event Handlers ---#
    def showEvent(self, se):
        self.__resizeAll(0, 0)

    def __resizeAll(self, index, pos):
        self.libMgr.resizeTreeview()

    def closeEvent(self, e):
        #If there are any unsaved changes, ask user what they want to do
        if (self.libMgr.anyUnsavedChanges()):
            msg = "There are unsaved changes. Quitting will discharges these changes."

            reply = QtGui.QMessageBox.question(self, "Warning", msg,
                                               QtGui.QMessageBox.Save,
                                               QtGui.QMessageBox.Discard,
                                               QtGui.QMessageBox.Cancel)

            if reply == QtGui.QMessageBox.Save:
                self.libMgr.saveAnyUnsavedChanges()
            elif reply == QtGui.QMessageBox.Cancel:
                e.ignore()
                return

        #Save window size, treeview width, output box height
        self.libMgr.saveWindowState(
            self.width(), self.height(),
            self.ui.splitter_leftright.widget(0).width())

        #Close any open dialogs
        if (self.aboutWin != None and not self.aboutWin.isHidden()):
            self.aboutWin.close()
        if (self.findWin != None and not self.findWin.isHidden()):
            self.findWin.close()
        if (self.repWin != None and not self.repWin.isHidden()):
            self.repWin.close()
        if (self.refWin != None and not self.refWin.isHidden()):
            self.refWin.close()

        if (self.parent != None):
            self.parent.ui.edit.setEnabled(True)

    #--- Opening Files ---#
    # Signal handler for open file action
    def __open(self):
        #Get the last dir opened by the user (from config file)
        lastDir = self.libMgr.getLastOpenDir()

        #Use file dialog to allow user to select one or more .fmls
        ofDialog = QtGui.QFileDialog(self)
        files = ofDialog.getOpenFileNames(caption='Open file(s)',
                                          directory=lastDir,
                                          filter='Files (*.fml *.lua)')

        #Only load files if the user select any
        if not files.isEmpty():
            #Place the chosen directory in the config file
            self.libMgr.setLastOpenDir(os.path.split(str(files[0]))[0])

            #Load the files
            self.loadFiles(files)

    #Loads a project file provided by sift
    def loadProject(self, fileDirs, projPath, projName, projType):
        #If not in linux or project_dir is not pointed to a build directory (ie bound to repo) or file_dirs is empty
        #Use the project_dir as the file_dirs since the project files will be with the .hlg
        if (not sys.platform.startswith('linux')
                or not re.search("obj_\w+_\w+", projPath)
                or len(fileDirs) == 0):
            fileDirs = projPath

        try:
            self.libMgr.loadProject(fileDirs, projPath, projName, projType)
        except:
            print "SiftFlow Load Error: "
            print "file_dirs: " + str(fileDirs)
            print "project_dir: " + str(projPath)
            print "project_name: " + str(projName)
            print "project_type: " + str(projType)
            print "".join(
                traceback.format_exception(sys.exc_info()[0],
                                           sys.exc_info()[1],
                                           sys.exc_info()[2]))
            return

        #Add the .all name and the repo name (None if not in repo) to the window title
        self.setWindowTitle('SiftFlow (' + (projName or "None") + ') (Repo: ' +
                            self.libMgr.getRepo() + ')')

    #Loads files not associated with a project file
    def loadFiles(self, args):
        #If no loaded project, set window title
        if (self.libMgr.getLoadedProjName() == ''):
            self.setWindowTitle('SiftFlow (No Project)')

        fileList = []
        #Load files the user has specified from command line args rather than a project from sift
        if (len(args) == 0):
            #If no args were given, check cwd for any .fmls and open them
            cwd = os.getcwd()
            for infile in glob.glob(os.path.join(cwd, '*.fml')):
                fileList.append(infile)

        elif (len(args) > 0):
            #Loop through the args and open files if they exist
            for x in range(len(args)):
                arg = str(args[x])
                if ((arg.endswith('.fml') or arg.endswith('.lua'))
                        and os.path.exists(arg)):
                    fileList.append(arg)
                else:
                    print arg + ' is not an fml or does not exist'

        #If there are files, open them
        if (len(fileList) > 0):
            try:
                self.libMgr.loadFiles(fileList)
            except:
                print "SiftFlow Load Error: "
                print "file list: " + str(fileList)
                print "".join(
                    traceback.format_exception(sys.exc_info()[0],
                                               sys.exc_info()[1],
                                               sys.exc_info()[2]))
                return

    def displayFlowFromSift(self, funcName, projName):
        #Use project name to get the correct filename for the function
        fileName = self.libMgr.getFileNameFromFuncName(projName, funcName)

        if not fileName:
            print "There was an error displaying the flow."
            return

        self.libMgr.displayFlow(fileName, projName, funcName)

    def __displayFromRecent(self, todisplay):
        fileName = todisplay[0]
        path = todisplay[1]
        proj = todisplay[2]
        funcName = todisplay[3]
        dIndex = todisplay[4]

        #If file is not in the loaded file list, add it
        if (not self.libMgr.isFileLoaded(fileName, path)):
            self.libMgr.loadFiles([os.path.join(path, fileName)])

        #Set up pathOrProj
        if (self.libMgr.isProjLoaded(proj)):
            pathOrProj = proj
        else:
            pathOrProj = path

        #Display the thing
        if (not funcName):
            self.libMgr.displayFml(fileName, pathOrProj)
        else:
            self.libMgr.displayFlow(fileName,
                                    pathOrProj,
                                    funcName,
                                    dIndex=dIndex)

    #--- Setup Functions ---#
    def __initMainWindow(self):
        #Set Main Window starting size
        self.resize(self.libMgr.getWindowSize())

        #Treeview (navigation) Tab Control Init
        self.ui.tabWidget_treeview.setCurrentIndex(0)

        #Set all layout margins to zero
        self.ui.gridLayout.setMargin(0)
        self.ui.gridLayout_2.setMargin(0)
        self.ui.gridLayout_3.setMargin(0)
        self.ui.gridLayout_4.setMargin(0)
        self.ui.gridLayout_5.setMargin(0)

        #Set stretch factors so the resize widgets know what ratio each side can be
        self.ui.splitter_leftright.setStretchFactor(1, 2)

        #Set Left frame contents sizes
        self.ui.splitter_leftright.widget(0).setMinimumWidth(125)
        self.ui.splitter_leftright.setSizes([
            self.libMgr.getTreeviewWidth(),
            self.ui.splitter_leftright.widget(1).width()
        ])

        #setup main icon
        icon = QtGui.QIcon()
        icon.addPixmap(
            QtGui.QPixmap(
                os.path.join(self.libMgr.getIconDir(), "SiftTeal.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.setWindowIcon(icon)

        #setup find icon
        iconF = QtGui.QIcon()
        iconF.addPixmap(
            QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "find.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionFind.setIcon(iconF)

        #setup reference icon
        iconRef = QtGui.QIcon()
        iconRef.addPixmap(
            QtGui.QPixmap(
                os.path.join(self.libMgr.getIconDir(), "findreference.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionReference.setIcon(iconRef)

        #setup reference icon
        iconRefInFiles = QtGui.QIcon()
        iconRefInFiles.addPixmap(
            QtGui.QPixmap(
                os.path.join(self.libMgr.getIconDir(),
                             "findreferenceinfiles.png")), QtGui.QIcon.Normal,
            QtGui.QIcon.Off)
        self.ui.actionReferenceInFiles.setIcon(iconRefInFiles)

        #setup undo icon
        iconU = QtGui.QIcon()
        iconU.addPixmap(
            QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "undo.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionUndo.setIcon(iconU)

        #setup redo icon
        iconRed = QtGui.QIcon()
        iconRed.addPixmap(
            QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "redo.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionRedo.setIcon(iconRed)

        #setup comment icon
        iconCom = QtGui.QIcon()
        iconCom.addPixmap(
            QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(),
                                       "comment.png")), QtGui.QIcon.Normal,
            QtGui.QIcon.Off)
        self.ui.actionComment.setIcon(iconCom)

        #setup uncomment icon
        iconUncom = QtGui.QIcon()
        iconUncom.addPixmap(
            QtGui.QPixmap(
                os.path.join(self.libMgr.getIconDir(), "uncomment.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionUncomment.setIcon(iconUncom)

        #setup indent icon
        iconIn = QtGui.QIcon()
        iconIn.addPixmap(
            QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(),
                                       "indent.png")), QtGui.QIcon.Normal,
            QtGui.QIcon.Off)
        self.ui.actionIndent.setIcon(iconIn)

        #setup unindent icon
        iconUnin = QtGui.QIcon()
        iconUnin.addPixmap(
            QtGui.QPixmap(
                os.path.join(self.libMgr.getIconDir(), "unindent.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionUnindent.setIcon(iconUnin)

        #setup goto icon
        iconGoto = QtGui.QIcon()
        iconGoto.addPixmap(
            QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "goto.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionGoto.setIcon(iconGoto)

        #setup open icon
        iconO = QtGui.QIcon()
        iconO.addPixmap(
            QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "open.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionOpen.setIcon(iconO)

        #setup save icon
        iconSave = QtGui.QIcon()
        iconSave.addPixmap(
            QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "save.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionSave.setIcon(iconSave)

        #setup saveall icon
        iconSaveAll = QtGui.QIcon()
        iconSaveAll.addPixmap(
            QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(),
                                       "saveall.png")), QtGui.QIcon.Normal,
            QtGui.QIcon.Off)
        self.ui.actionSave_All.setIcon(iconSaveAll)

        #setup download icon
        iconDownload = QtGui.QIcon()
        iconDownload.addPixmap(
            QtGui.QPixmap(
                os.path.join(self.libMgr.getIconDir(), "download.png")),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionDownload.setIcon(iconDownload)

        #Create File menu
        #self.ui.menuNew = QtGui.QMenu('New')
        #self.ui.actionNewFlow = QtGui.QAction(self.ui.menuNew)
        #self.ui.actionNewFlow.setObjectName('actionNewFlow')
        #self.ui.actionNewFlow.setText('Flow')
        #self.ui.menuNew.addAction(self.ui.actionNewFlow)
        #self.ui.menuFile.addMenu(self.ui.menuNew)

        #self.ui.menuFile.addSeparator()
        self.ui.menuFile.addAction(self.ui.actionOpen)
        self.ui.menuFile.addSeparator()
        self.ui.menuFile.addAction(self.ui.actionSave)
        #self.ui.menuFile.addAction(self.ui.actionSave_All)
        self.ui.menuFile.addSeparator()

        #build recent menu
        self.ui.menuRecent = QtGui.QMenu(self.ui.menuFile)
        self.ui.menuRecent.setTitle('Recent')
        self.ui.menuFile.addMenu(self.ui.menuRecent)

        self.ui.menuFile.addSeparator()
        self.ui.menuFile.addAction(self.ui.actionExit)

        #build...build menu
        self.ui.menuBuild.addAction(self.ui.actionDownload)

    def __fillMenuRecent(self):
        list = self.libMgr.getRecentList()
        self.ui.menuRecent.clear()

        for item in reversed(list):
            action = QtGui.QAction(self.ui.menuRecent)

            #Display the flow name, or .fml if that all there is, tack on dIndex if there
            dIndex = ''
            if item[4]:
                dIndex = '(' + str(item[4]) + ')'

            action.setText((item[3] or item[0]) + dIndex)

            #Pass in path:flow to the display function when the action is clicked for easy displaying
            receiver = lambda todisplay=item: self.__displayFromRecent(
                todisplay)
            action.connect(action, QtCore.SIGNAL("triggered()"), receiver)
            self.ui.menuRecent.addAction(action)

    def __fillMenuBuild(self):
        #build...build menu
        self.ui.menuBuild.addAction(self.ui.actionDownload)
示例#15
0
 def __about(self):
     if (self.aboutWin == None or self.aboutWin.isHidden()):
         self.aboutWin = About(self, self.libMgr)
         self.aboutWin.exec_()
示例#16
0
 def Help_About(self, event=None):
     import About
     About.Open()
示例#17
0
def about():
    """
    Метод вызывающий главнй метод класса About
    :rtype: object
    """
    About.mainee()
示例#18
0
try:
    from Tkinter import *
except ImportError:
    from tkinter import *

try:
    import ttk
    py3 = False
except ImportError:
    import tkinter.ttk as ttk
    py3 = True


def init(top, gui, *args, **kwargs):
    global w, top_level, root
    w = gui
    top_level = top
    root = top


def destroy_window():
    # Function which closes the window.
    global top_level
    top_level.destroy()
    top_level = None


if __name__ == '__main__':
    import About
    About.vp_start_gui()
示例#19
0
    def OnInit(self):
        Preferences.initScreenVars()

        # i18n support
        self.locale = wx.Locale(Preferences.i18nLanguage)
        wx.Locale.AddCatalogLookupPathPrefix(os.path.join(Preferences.pyPath, 'locale'))
        if hasattr(sys, 'frozen'):
            self.locale.AddCatalog('wxstd')   
        self.locale.AddCatalog('boa') 

        wx.ToolTip.Enable(True)
        if Preferences.debugMode == 'release':
            self.SetAssertMode(wx.PYAPP_ASSERT_SUPPRESS)
        elif Preferences.debugMode == 'development':
            self.SetAssertMode(wx.PYAPP_ASSERT_EXCEPTION)


        conf = Utils.createAndReadConfig('Explorer')
        if not conf.has_section('splash'):
            conf.add_section('splash')
            modTot = 1
        else:
            modTot = conf.getint('splash', 'modulecount')
        fileTot = len(eval(conf.get('editor', 'openfiles'), {}))

        abt = About.createSplash(None, modTot, fileTot)
        try:
            abt.Show()
            abt.Update()
            # Let the splash screen repaint
            wx.Yield()

            # Imported here to initialise core features and plug-ins
            import PaletteMapping

            print 'creating Palette'
            import Palette
            self.main = Palette.BoaFrame(None, -1, self)

            print 'creating Inspector'
            import Inspector
            inspector = Inspector.InspectorFrame(self.main)

            print 'creating Editor'
            import Editor
            editor = Editor.EditorFrame(self.main, -1, inspector, wx.Menu(),
                self.main.componentSB, self, self.main)
            self.SetTopWindow(editor)

            inspector.editor = editor

            conf.set('splash', 'modulecount', str(len(sys.modules)))
            try:
                Utils.writeConfig(conf)
            except IOError, err:
                startupErrors.append(_('Error writing config file: %s\nPlease '
              'ensure that the Explorer.*.cfg file is not read only.')% str(err))

            if not emptyEditor:
                editor.restoreEditorState()

            self.main.initPalette(inspector, editor)

    ##            editor.setupToolBar()

            import Help
            if not Preferences.delayInitHelp:
                print 'initialising help'
                Help.initHelp()

            global constricted
            constricted = constricted or Preferences.suBoaConstricted

            print 'showing main frames <<100/100>>'
            if constricted:
                editor.CenterOnScreen()
                inspector.CenterOnScreen()
                inspector.initSashes()
            else:
                self.main.Show()
                inspector.Show()
                # For some reason the splitters have to be visible on GTK before they
                # can be sized.
                inspector.initSashes()

            editor.Show()
            editor.doAfterShownActions()

            # Call startup files after complete editor initialisation
            global startupfile
            if Preferences.suExecPythonStartup and startupEnv:
                startupfile = startupEnv

            if editor.shell:
                editor.shell.execStartupScript(startupfile)
示例#20
0
 def showAbout(self):
     self.aboutBox = About.About()
     self.aboutBox.show()
示例#21
0
 def on_author(self):
     import About
     director.push(SlideInTTransition(About.get_about()))
示例#22
0
    def game_intro(self):

        self.about = About.About()
        self.func = Functions.Functions()
        self.high = Highscore()
        self.intro = True
        self.sett = Settings(self.selected_vol, self.selected_music)

        bg_y = 0
        while (self.intro):
            py.display.set_caption("Main")

            rel_y = bg_y % bg.get_rect().height
            display_screen.blit(bg, (0, rel_y - bg.get_rect().height))
            if rel_y < display_height:
                display_screen.blit(bg, (0, rel_y))
            bg_y += 0.1

            # BUTTONS
            mg_menu_button = self.func.button(
                "Mini Games", WHITE, display_width / 2 - main_menu_buttonx / 2,
                225, main_menu_buttonx, main_menu_buttony, IACOLOR, ACOLOR)

            highscores_button = self.func.button(
                "Highscores", WHITE, display_width / 2 - main_menu_buttonx / 2,
                300, main_menu_buttonx, main_menu_buttony, IACOLOR, ACOLOR)

            settings_button = self.func.button(
                "Settings", WHITE, display_width / 2 - main_menu_buttonx / 2,
                375, main_menu_buttonx, main_menu_buttony, IACOLOR, ACOLOR)

            instr_menu_button = self.func.button(
                "About", WHITE, display_width / 2 - main_menu_buttonx / 2, 450,
                main_menu_buttonx, main_menu_buttony, IACOLOR, ACOLOR)

            exit_button = self.func.button("Exit", WHITE, 20,
                                           display_height - instr_buttony - 20,
                                           instr_buttonx, instr_buttony,
                                           IACOLOR, ACOLOR)

            # TEXT
            text_surface, text_rect = self.func.text_objects(
                "MAIN MENU", large_text, WHITE)
            text_rect.center = (display_width / 2, 150)
            display_screen.blit(text_surface, text_rect)

            for event in py.event.get():
                if event.type == py.QUIT:
                    py.quit()
                    quit()
                if event.type == py.MOUSEBUTTONDOWN:
                    mouse_pos = py.mouse.get_pos()
                    if mg_menu_button.collidepoint(mouse_pos):
                        self.value = 'mini'
                        self.intro = False
                    if highscores_button.collidepoint(mouse_pos):
                        self.high.loop()
                    if instr_menu_button.collidepoint(mouse_pos):
                        self.about.loop()
                    if settings_button.collidepoint(mouse_pos):
                        self.selected_vol, self.selected_music = self.sett.loop(
                        )
                    if exit_button.collidepoint(mouse_pos):
                        py.quit()
                        quit()

            py.display.update()

        return self.selected_vol, self.selected_music, self.value
示例#23
0
 def OnAbout(self, event):
     dlg = About.AboutDialog(self)
     dlg.ShowModal()
     dlg.Destroy()
     event.Skip()
示例#24
0
 def abt(self):
     self.about = About.About()
     self.about.setWindowFlags(Qt.Window | Qt.MSWindowsFixedSizeDialogHint)
     self.about.show()
示例#25
0
 def _handle_about(self):
     self._stop_autostart()
     self.window.withdraw()
     about = About.About(tk.Toplevel(self.window), self.prefs)
     about.show()
     self.window.deiconify()
示例#26
0
 def about(self):
     about.About("about").initUI()
示例#27
0
class SiftFlow(QtGui.QMainWindow):
    def __init__(self, parent=None):
        #If we were opened from the base sift (not the gui) setup the app internaly
        if (parent == None):
            self.app = QtGui.QApplication(sys.argv)
            self.app.setOrganizationName("Hewlett-Packard")
            self.app.setOrganizationDomain("hp.com")
            self.app.setApplicationName("SiftFlow")
    
            if (sys.platform.startswith("darwin")):
                self.app.setStyle("Cleanlooks")

        #Setup the window
        QtGui.QMainWindow.__init__(self)
        self.parent = parent

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        #Declare interface object with backend
        self.libMgr = SFLibManager(self, self.ui)

        #Do additional Window setup
        self.__initMainWindow()

        #Only want one reference window at a time
        self.refWin = None
        self.aboutWin = None
        self.findWin = None
        self.repWin = None

        #Set up actions and signals
        QtCore.QObject.connect(self.ui.actionAbout, QtCore.SIGNAL("triggered()"), self.__about)
        QtCore.QObject.connect(self.ui.actionFind, QtCore.SIGNAL("triggered()"), self.__find)
        QtCore.QObject.connect(self.ui.actionFindInFiles, QtCore.SIGNAL("triggered()"), self.__findInFiles)
        QtCore.QObject.connect(self.ui.actionReference, QtCore.SIGNAL("triggered()"), self.reference)
        QtCore.QObject.connect(self.ui.actionReferenceInFiles, QtCore.SIGNAL("triggered()"), self.referenceInFiles)
        QtCore.QObject.connect(self.ui.actionCut, QtCore.SIGNAL("triggered()"), self.__cut)
        QtCore.QObject.connect(self.ui.actionCopy, QtCore.SIGNAL("triggered()"), self.__copy)
        QtCore.QObject.connect(self.ui.actionUndo, QtCore.SIGNAL("triggered()"), self.__undo)
        QtCore.QObject.connect(self.ui.actionRedo, QtCore.SIGNAL("triggered()"), self.__redo)
        QtCore.QObject.connect(self.ui.actionGoto, QtCore.SIGNAL("triggered()"), self.__goto)
        QtCore.QObject.connect(self.ui.actionIndent, QtCore.SIGNAL("triggered()"), self.__indent)
        QtCore.QObject.connect(self.ui.actionUnindent, QtCore.SIGNAL("triggered()"), self.__unindent)
        QtCore.QObject.connect(self.ui.actionComment, QtCore.SIGNAL("triggered()"), self.__comment)
        QtCore.QObject.connect(self.ui.actionUncomment, QtCore.SIGNAL("triggered()"), self.__uncomment)
        QtCore.QObject.connect(self.ui.actionPaste, QtCore.SIGNAL("triggered()"), self.__paste)
        QtCore.QObject.connect(self.ui.actionDownload, QtCore.SIGNAL("triggered()"), self.__download)

        QtCore.QObject.connect(self.ui.treeWidget_proj, QtCore.SIGNAL("itemSelectionChanged()"), self.__projSelectionChanged)
        QtCore.QObject.connect(self.ui.treeWidget_nonProj, QtCore.SIGNAL("itemSelectionChanged()"), self.__nonProjSelectionChanged)
        QtCore.QObject.connect(self.ui.splitter_leftright, QtCore.SIGNAL("splitterMoved(int, int)"), self.__resizeAll)

        #QtCore.QObject.connect(self.ui.actionNewFlow, QtCore.SIGNAL("triggered()"), self.__newFlow)
        QtCore.QObject.connect(self.ui.actionOpen, QtCore.SIGNAL("triggered()"), self.__open)
        QtCore.QObject.connect(self.ui.actionSave, QtCore.SIGNAL("triggered()"), self.__save)
        #QtCore.QObject.connect(self.ui.actionSave_All, QtCore.SIGNAL("triggered()"), self.__saveAll)
        QtCore.QObject.connect(self.ui.menuRecent, QtCore.SIGNAL("aboutToShow()"), self.__fillMenuRecent)
        QtCore.QObject.connect(self.ui.menuBuild, QtCore.SIGNAL("aboutToShow()"), self.__fillMenuBuild)

        #SiftFlow, show thyself!!
        if(parent == None): self.show()

    def run(self):
        """Run the main QT event loop"""
        self.app.exec_()

    #--- Child Windows ---#
    def __about(self):
        if(self.aboutWin == None or self.aboutWin.isHidden()):
            self.aboutWin = About(self, self.libMgr)
            self.aboutWin.exec_()

    def __find(self):
        if(self.findWin == None or self.findWin.isHidden()):
            self.findWin = Find(self, self.libMgr)
            self.findWin.show()

    def reference(self, text='none', flags=None, isCurrent=True):
        if(self.refWin == None or not self.refWin.isVisible()):
            self.refWin = Reference(self, self.libMgr)
            result = self.refWin.addSearch(text, flags, isCurrent)
            if(isinstance(result, str) and result == 'noselection'):
                QtGui.QMessageBox.about(self, "Selection Status", "There is no text selected.")
            elif(result):
                self.refWin.show()
            else:
                QtGui.QMessageBox.about(self, "Match Status", "There are no more matches.")
        elif(self.refWin.isVisible()): #the window is open, reset
            if(not self.refWin.addSearch(text, flags, isCurrent)):
                QtGui.QMessageBox.about(self, "Match Status", "There are no more matches.")

    def referenceInFiles(self):
        self.reference(isCurrent='all')

    #--- Signal Handlers ---#
    def __projSelectionChanged(self):
        self.libMgr.tvProjUpdate()

    def __nonProjSelectionChanged(self):
        self.libMgr.tvNonProjUpdate()

    def __cut(self):
        self.libMgr.cut()

    def __copy(self):
        self.libMgr.copy()

    def __paste(self):
        self.libMgr.paste()

    def __findInFiles(self):
        findWin = Find(self, self.libMgr)
        findWin.findInFiles()
        findWin.exec_()

    def __undo(self):
        self.libMgr.undo()

    def __redo(self):
        self.libMgr.redo()

    def __goto(self):
        lineNum, ok = QtGui.QInputDialog.getText(self, 'Go to..', 'Go To Line: ')
        if ok:
            self.libMgr.setCursorToReference(int(lineNum) - 1, 0)

    def __indent(self):
        self.libMgr.indent()

    def __unindent(self):
        self.libMgr.unindent()

    def __comment(self):
        self.libMgr.comment()

    def __uncomment(self):
        self.libMgr.uncomment()

    def __newFlow(self):
        print 'new flow'

    def __save(self):
        result = self.libMgr.saveCurrentTab()

        #Reset the reference window if it is open, to reflect any changes in the files after saving
        if(self.refWin and self.refWin.isVisible()): #the window is open
            self.refWin.resetTabs()

    #def __saveAll(self):
        #For now I am removing save all from the ui, but will leave the functionality in.
        #Save All would rarely be used and caused a few hard to solve cunundrums with file conflicts
        #when a user had unsaved changes in both fmls and flows from those fmls. If in the future, this 
        #feature is demanded, then all that needs to be done is to reattach the action to the toolbar and
        #uncomment this function, the signal and file menu entry near the bottom of this file
        
        #result = self.libMgr.saveAllTabs()

        #Reset the reference window if it is open, to reflect any changes in the files after saving
        #if(self.refWin and self.refWin.isVisible()): #the window is open
            #self.refWin.resetTabs()

    def __download(self):
        #Cannot download if there is no project loaded
        if(not self.libMgr.isProjLoaded()):
            self.libMgr.printError("Download failed!", 10)
            QtGui.QMessageBox.about(self, "Download Failed", "No Project Loaded.")
            return

        #Get a list of all files changed since .all was build
        dList = self.libMgr.getDownloadFileList()

        #If files have changed since the .all was built, download them to printer
        if(len(dList) > 0):
            #Turn that list into the command string
            cmd = "download " + " ".join(dList)

            #Send command to sift
            self.parent.parse(cmd)

        #If no files have changed, tell user and do nothing
        else:
            self.libMgr.out("No changed files to download", 6)

    #--- Event Handlers ---#
    def showEvent(self, se):
        self.__resizeAll(0, 0)

    def __resizeAll(self, index, pos):
        self.libMgr.resizeTreeview()

    def closeEvent(self, e):
        #If there are any unsaved changes, ask user what they want to do
        if(self.libMgr.anyUnsavedChanges()):
            msg = "There are unsaved changes. Quitting will discharges these changes."

            reply = QtGui.QMessageBox.question(self, "Warning", msg, QtGui.QMessageBox.Save, 
                                                QtGui.QMessageBox.Discard, QtGui.QMessageBox.Cancel)
    
            if reply == QtGui.QMessageBox.Save:
                self.libMgr.saveAnyUnsavedChanges()
            elif reply == QtGui.QMessageBox.Cancel:
                e.ignore()
                return

        #Save window size, treeview width, output box height
        self.libMgr.saveWindowState(self.width(), self.height(), 
                                    self.ui.splitter_leftright.widget(0).width())

        #Close any open dialogs
        if(self.aboutWin != None and not self.aboutWin.isHidden()):
            self.aboutWin.close()
        if(self.findWin != None and not self.findWin.isHidden()):
            self.findWin.close()
        if(self.repWin != None and not self.repWin.isHidden()):
            self.repWin.close()
        if(self.refWin != None and not self.refWin.isHidden()):
            self.refWin.close()

        if (self.parent != None):
            self.parent.ui.edit.setEnabled(True)

    #--- Opening Files ---#
    # Signal handler for open file action
    def __open(self):
        #Get the last dir opened by the user (from config file)
        lastDir = self.libMgr.getLastOpenDir()
        
        #Use file dialog to allow user to select one or more .fmls
        ofDialog = QtGui.QFileDialog(self)
        files = ofDialog.getOpenFileNames(caption='Open file(s)', 
                                          directory=lastDir, 
                                          filter='Files (*.fml *.lua)')

        #Only load files if the user select any
        if not files.isEmpty():
            #Place the chosen directory in the config file
            self.libMgr.setLastOpenDir(os.path.split(str(files[0]))[0])

            #Load the files
            self.loadFiles(files)

    #Loads a project file provided by sift
    def loadProject(self, fileDirs, projPath, projName, projType):
        #If not in linux or project_dir is not pointed to a build directory (ie bound to repo) or file_dirs is empty
        #Use the project_dir as the file_dirs since the project files will be with the .hlg
        if(not sys.platform.startswith('linux') or 
           not re.search("obj_\w+_\w+", projPath) or
           len(fileDirs) == 0):
            fileDirs = projPath

        try:
            self.libMgr.loadProject(fileDirs, projPath, projName, projType)
        except:
            print "SiftFlow Load Error: "
            print "file_dirs: " + str(fileDirs)
            print "project_dir: " + str(projPath)
            print "project_name: " + str(projName)
            print "project_type: " + str(projType)
            print "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]))
            return

        #Add the .all name and the repo name (None if not in repo) to the window title
        self.setWindowTitle('SiftFlow (' + (projName or "None") + ') (Repo: ' + self.libMgr.getRepo() + ')')

    #Loads files not associated with a project file
    def loadFiles(self, args):
        #If no loaded project, set window title
        if(self.libMgr.getLoadedProjName() == ''):
            self.setWindowTitle('SiftFlow (No Project)') 

        fileList = []
        #Load files the user has specified from command line args rather than a project from sift
        if(len(args) == 0):
            #If no args were given, check cwd for any .fmls and open them
            cwd = os.getcwd()
            for infile in glob.glob(os.path.join(cwd, '*.fml')):
                fileList.append(infile)

        elif(len(args) > 0):
            #Loop through the args and open files if they exist
            for x in range(len(args)):
                arg = str(args[x]) 
                if ((arg.endswith('.fml') or arg.endswith('.lua')) and 
                     os.path.exists(arg)):
                    fileList.append(arg)
                else:
                    print arg + ' is not an fml or does not exist'

        #If there are files, open them
        if(len(fileList) > 0):
            try:
                self.libMgr.loadFiles(fileList)
            except:
                print "SiftFlow Load Error: "
                print "file list: " + str(fileList)
                print "".join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]))
                return

    def displayFlowFromSift(self, funcName, projName):
        #Use project name to get the correct filename for the function
        fileName = self.libMgr.getFileNameFromFuncName(projName, funcName)

        if not fileName:
            print "There was an error displaying the flow."
            return

        self.libMgr.displayFlow(fileName, projName, funcName)

    def __displayFromRecent(self, todisplay):
        fileName = todisplay[0] 
        path = todisplay[1]
        proj = todisplay[2]
        funcName = todisplay[3]
        dIndex = todisplay[4]

        #If file is not in the loaded file list, add it
        if(not self.libMgr.isFileLoaded(fileName, path)):
            self.libMgr.loadFiles([os.path.join(path,fileName)])

        #Set up pathOrProj
        if(self.libMgr.isProjLoaded(proj)):
            pathOrProj = proj
        else:
            pathOrProj = path

        #Display the thing
        if(not funcName):
            self.libMgr.displayFml(fileName, pathOrProj)
        else:
            self.libMgr.displayFlow(fileName, pathOrProj, funcName, dIndex=dIndex)

    #--- Setup Functions ---#
    def __initMainWindow(self):
        #Set Main Window starting size
        self.resize(self.libMgr.getWindowSize())

        #Treeview (navigation) Tab Control Init
        self.ui.tabWidget_treeview.setCurrentIndex(0)

        #Set all layout margins to zero
        self.ui.gridLayout.setMargin(0)
        self.ui.gridLayout_2.setMargin(0)
        self.ui.gridLayout_3.setMargin(0)
        self.ui.gridLayout_4.setMargin(0)
        self.ui.gridLayout_5.setMargin(0)

        #Set stretch factors so the resize widgets know what ratio each side can be
        self.ui.splitter_leftright.setStretchFactor(1, 2)

        #Set Left frame contents sizes
        self.ui.splitter_leftright.widget(0).setMinimumWidth(125)
        self.ui.splitter_leftright.setSizes([self.libMgr.getTreeviewWidth(), self.ui.splitter_leftright.widget(1).width()])

        #setup main icon
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "SiftTeal.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.setWindowIcon(icon)

        #setup find icon
        iconF = QtGui.QIcon()
        iconF.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "find.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionFind.setIcon(iconF)

        #setup reference icon
        iconRef = QtGui.QIcon()
        iconRef.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "findreference.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionReference.setIcon(iconRef)

        #setup reference icon
        iconRefInFiles = QtGui.QIcon()
        iconRefInFiles.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "findreferenceinfiles.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionReferenceInFiles.setIcon(iconRefInFiles)

        #setup undo icon
        iconU = QtGui.QIcon()
        iconU.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "undo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionUndo.setIcon(iconU)

        #setup redo icon
        iconRed = QtGui.QIcon()
        iconRed.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "redo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionRedo.setIcon(iconRed)

        #setup comment icon
        iconCom = QtGui.QIcon()
        iconCom.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "comment.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionComment.setIcon(iconCom)

        #setup uncomment icon
        iconUncom = QtGui.QIcon()
        iconUncom.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "uncomment.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionUncomment.setIcon(iconUncom)

        #setup indent icon
        iconIn = QtGui.QIcon()
        iconIn.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "indent.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionIndent.setIcon(iconIn)

        #setup unindent icon
        iconUnin = QtGui.QIcon()
        iconUnin.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "unindent.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionUnindent.setIcon(iconUnin)

        #setup goto icon
        iconGoto = QtGui.QIcon()
        iconGoto.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "goto.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionGoto.setIcon(iconGoto)

        #setup open icon
        iconO = QtGui.QIcon()
        iconO.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "open.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionOpen.setIcon(iconO)

        #setup save icon
        iconSave = QtGui.QIcon()
        iconSave.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "save.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionSave.setIcon(iconSave)

        #setup saveall icon
        iconSaveAll = QtGui.QIcon()
        iconSaveAll.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "saveall.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionSave_All.setIcon(iconSaveAll)

        #setup download icon
        iconDownload = QtGui.QIcon()
        iconDownload.addPixmap(QtGui.QPixmap(os.path.join(self.libMgr.getIconDir(), "download.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.ui.actionDownload.setIcon(iconDownload)

        #Create File menu
        #self.ui.menuNew = QtGui.QMenu('New')
        #self.ui.actionNewFlow = QtGui.QAction(self.ui.menuNew)
        #self.ui.actionNewFlow.setObjectName('actionNewFlow')
        #self.ui.actionNewFlow.setText('Flow')
        #self.ui.menuNew.addAction(self.ui.actionNewFlow)
        #self.ui.menuFile.addMenu(self.ui.menuNew)

        #self.ui.menuFile.addSeparator()
        self.ui.menuFile.addAction(self.ui.actionOpen)
        self.ui.menuFile.addSeparator()
        self.ui.menuFile.addAction(self.ui.actionSave)
        #self.ui.menuFile.addAction(self.ui.actionSave_All) 
        self.ui.menuFile.addSeparator()

        #build recent menu
        self.ui.menuRecent = QtGui.QMenu(self.ui.menuFile)
        self.ui.menuRecent.setTitle('Recent')
        self.ui.menuFile.addMenu(self.ui.menuRecent)

        self.ui.menuFile.addSeparator()
        self.ui.menuFile.addAction(self.ui.actionExit)

        #build...build menu
        self.ui.menuBuild.addAction(self.ui.actionDownload)

    def __fillMenuRecent(self):
        list = self.libMgr.getRecentList()
        self.ui.menuRecent.clear()

        for item in reversed(list):
            action = QtGui.QAction(self.ui.menuRecent)

            #Display the flow name, or .fml if that all there is, tack on dIndex if there
            dIndex = ''
            if item[4]:
                dIndex = '(' + str(item[4]) + ')'

            action.setText((item[3] or item[0]) + dIndex)

            #Pass in path:flow to the display function when the action is clicked for easy displaying
            receiver = lambda todisplay=item: self.__displayFromRecent(todisplay)
            action.connect(action, QtCore.SIGNAL("triggered()"), receiver)
            self.ui.menuRecent.addAction(action)

    def __fillMenuBuild(self):
        #build...build menu
        self.ui.menuBuild.addAction(self.ui.actionDownload)
示例#28
0
    def __init__(
        self,
        master,
    ):
        master.wm_title("Archive")
        self.master = master
        master.maxsize(420, 470)
        master.minsize(420, 470)
        #master.geometry('420x470+750+305')
        self.master.geometry('420x470+750+305')
        geo = Functions.geo_center_screen(self, 420, 470)

        # Menus---------------------------------------------------------------------------------------------------------
        menubar = Menu(master)

        filemenu = Menu(menubar, tearoff=0)
        filemenu.add_command(
            label="Profiles",
            command=lambda: Profiles.profile_window(self, master))
        filemenu.add_command(label="Clear All",
                             command=lambda: Functions.clear_all(self))
        filemenu.add_command(label="Exit", command=master.quit)
        menubar.add_cascade(label="File", menu=filemenu)

        helpmenu = Menu(menubar, tearoff=0)
        helpmenu.add_command(label="About",
                             command=lambda: About.about_window(self))
        menubar.add_cascade(label="Help", menu=helpmenu)

        master.config(menu=menubar)

        # Paths---------------------------------------------------------------------------------------------------------
        paths = ttk.Frame(master)
        paths.grid(padx=5, pady=5, sticky=W, row=1, column=0)

        self.src_btn = ttk.Button(paths,
                                  text="Source",
                                  command=lambda: Functions.select_src(self))
        self.src_btn.grid(pady=5, row=0, column=0)
        self.src_label = ttk.Label(paths,
                                   text=Functions.srcdir,
                                   justify=LEFT,
                                   width=64)
        self.src_label.grid(padx=5,
                            pady=5,
                            sticky=SW,
                            row=0,
                            column=1,
                            columnspan=2)

        self.dst_btn = ttk.Button(paths,
                                  text="Destination",
                                  command=lambda: Functions.select_dst(self))
        self.dst_label = ttk.Label(paths,
                                   justify=LEFT,
                                   width=64,
                                   text=Functions.dstdir)
        self.dst_btn.grid(pady=5, row=1, column=0)
        self.dst_label.grid(padx=5,
                            pady=5,
                            sticky=SW,
                            row=1,
                            column=1,
                            columnspan=2)

        # Options-------------------------------------------------------------------------------------------------------
        options = ttk.Frame(master)
        options.grid(padx=5, pady=5, sticky=W, row=2, column=0)

        self.options_text = ttk.Label(options, text="Select archive option.")
        self.options_text.grid(pady=5, sticky=W, row=0, column=0, columnspan=3)

        self.mod_create_opt0 = ttk.Radiobutton(
            options,
            text="",
            variable=Functions.mod_or_create,
            value=0,
        )

        self.mod_create_opt1 = ttk.Radiobutton(
            options,
            text="MODIFIED since last archive performed.",
            variable=Functions.mod_or_create,
            value=1,
            command=lambda: Functions.options_set(self, option="m"))
        self.mod_create_opt1.grid(padx=2, sticky=W, row=1, column=0)

        self.mod_create_opt2 = ttk.Radiobutton(
            options,
            text="CREATED  since last archive performed.",
            variable=Functions.mod_or_create,
            value=2,
            command=lambda: Functions.options_set(self, option="c"))
        self.mod_create_opt2.grid(padx=2, sticky=W, row=2, column=0)

        # File info-----------------------------------------------------------------------------------------------------
        feedback = ttk.Frame(master)
        feedback.grid(padx=5, row=3, column=0, sticky=W)

        ttk.Label(feedback,
                  text="The following files will be copied").grid(row=0,
                                                                  column=0,
                                                                  sticky=W,
                                                                  pady=5)

        self.display_files = Text\
            (feedback, width=50, height=10, state='disabled')
        self.display_files.grid(pady=5, row=1, column=0, sticky=W)

        self.archive_btn = ttk.Button\
            (feedback, text="Archive Now", state=DISABLED, command=lambda: Functions.archive(self))
        self.archive_btn.grid(pady=5, row=2, column=0, sticky=W)

        # Misc. info----------------------------------------------------------------------------------------------------
        misc_info = ttk.Frame(master)
        misc_info.grid(padx=5, row=4, column=0, sticky=W)

        self.info_1 = ttk.Label(misc_info, )
        self.info_1.grid(pady=(3, 0), row=0, column=0, sticky=S + W)

        self.info_2 = ttk.Label(misc_info)
        self.info_2.grid(row=1, column=0, sticky=S + W)

        self.info_3 = ttk.Label(misc_info)
        self.info_3.grid(row=2, column=0, sticky=S + W)

        self.info_4 = ttk.Label(misc_info)
        self.info_4.grid(row=3, column=0, sticky=S + W)

        Functions.refresh(self)
示例#29
0
 def __about(self):
     if(self.aboutWin == None or self.aboutWin.isHidden()):
         self.aboutWin = About(self, self.libMgr)
         self.aboutWin.exec_()
示例#30
0
 def about(self, event=None):
     About.Window(self)
示例#31
0
 def trigger(self, sCmd):
     global xLEDialog
     try:
         if sCmd == "About":
             import About
             xAboutDialog = About.AboutGrammalecte(self.ctx)
             xAboutDialog.run(self.sLang)
         elif sCmd.startswith("CJ"):
             import Conjugueur
             xConjDialog = Conjugueur.Conjugueur(self.ctx)
             if sCmd[2:3] == "/":
                 xConjDialog.run(sCmd[3:])
             else:
                 xConjDialog.run()
         elif sCmd == "TF":
             import TextFormatter
             xTFDialog = TextFormatter.TextFormatter(self.ctx)
             xTFDialog.run(self.sLang)
         elif sCmd == "DI":
             import DictOptions
             xDODialog = DictOptions.DictOptions(self.ctx)
             xDODialog.run(self.sLang)
         elif sCmd.startswith("LE"):
             import LexiconEditor
             if not xLEDialog or xLEDialog.bClosed:
                 xLEDialog = LexiconEditor.LexiconEditor(self.ctx)
                 if sCmd[2:3] == "/":
                     xLEDialog.run(self.sLang, sCmd[3:])
                 else:
                     xLEDialog.run(self.sLang)
             elif sCmd[2:3] == "/":
                 xLEDialog.newEntry(sCmd[3:])
         elif sCmd == "MA":
             import Author
             xAuthorDialog = Author.Author(self.ctx)
             xAuthorDialog.run(self.sLang)
         elif sCmd == "OP":
             import Options
             xGCDialog = Options.GC_Options(self.ctx)
             xGCDialog.run(self.sLang)
         elif sCmd == "EN":
             import Enumerator
             xEnumDialog = Enumerator.Enumerator(self.ctx)
             xEnumDialog.run(self.sLang)
         elif sCmd == "GO":
             import GraphicOptions
             xGODialog = GraphicOptions.GraphicOptions(self.ctx)
             xGODialog.run(self.sLang)
         elif sCmd.startswith("FA/"):
             findAll(sCmd[6:], (sCmd[3:4] == "y"), (sCmd[4:5] == "y"))
         elif sCmd == "Console":
             helpers.startConsole()
         # elif sCmd.startswith("URL/"):
         #     # Call from context menu to launch URL?
         #     # http://opengrok.libreoffice.org/xref/core/sw/source/ui/lingu/olmenu.cxx#785
         #     xSystemShellExecute = self.ctx.getServiceManager().createInstanceWithContext('com.sun.star.system.SystemShellExecute', self.ctx)
         #     xSystemShellExecute.execute(url, "", uno.getConstantByName("com.sun.star.system.SystemShellExecuteFlags.URIS_ONLY"))
         elif sCmd == "None":
             pass
         else:
             print("Unknown command: " + str(sCmd))
     except:
         traceback.print_exc()
示例#32
0
 def about(self):
     About.Window(self)
示例#33
0
 def showAbout(self):
     self.aboutWidget = About.AboutWidget()
     self.aboutWidget.show()