Ejemplo n.º 1
0
    def prompt_for_account(self):
        """
        Prompt the user for an account to use, in a base58-encoded format:
        - master key seed: Grants read-write access.
          (assumes the master key pair is not disabled)
        - classic address. Grants read-only access.
        - X-address. Grants read-only access.

        Exits with error code 1 if the user cancels the dialog, if the input
        doesn't match any of the formats, or if the user inputs an X-address
        intended for use on a different network type (test/non-test).

        Populates the classic address and X-address labels in the UI.

        Returns (classic_address, wallet) where wallet is None in read-only mode
        """
        account_dialog = wx.TextEntryDialog(
            self, "Please enter an account address (for read-only)"
            " or your secret (for read-write access)",
            caption="Enter account",
            value="rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe")
        account_dialog.Bind(wx.EVT_TEXT, self.toggle_dialog_style)

        if account_dialog.ShowModal() != wx.ID_OK:
            # If the user presses Cancel on the account entry, exit the app.
            exit(1)

        value = account_dialog.GetValue().strip()
        account_dialog.Destroy()

        classic_address = ""
        wallet = None
        x_address = ""

        if xrpl.core.addresscodec.is_valid_xaddress(value):
            x_address = value
            classic_address, dest_tag, test_network = xrpl.core.addresscodec.xaddress_to_classic_address(
                value)
            if test_network != self.test_network:
                on_net = "a test network" if self.test_network else "Mainnet"
                print(
                    f"X-address {value} is meant for a different network type"
                    f"than this client is connected to."
                    f"(Client is on: {on_net})")
                exit(1)

        elif xrpl.core.addresscodec.is_valid_classic_address(value):
            classic_address = value
            x_address = xrpl.core.addresscodec.classic_address_to_xaddress(
                value, tag=None, is_test_network=self.test_network)

        else:
            try:
                # Check if it's a valid seed
                seed_bytes, alg = xrpl.core.addresscodec.decode_seed(value)
                wallet = xrpl.wallet.Wallet(seed=value, sequence=0)
                x_address = wallet.get_xaddress(is_test=self.test_network)
                classic_address = wallet.classic_address
            except Exception as e:
                print(e)
                exit(1)

        # Update the UI with the address values
        self.st_classic_address.SetLabel(classic_address)
        self.st_x_address.SetLabel(x_address)

        return classic_address, wallet
Ejemplo n.º 2
0
 def OnAdd(self, event):
     dialog = wx.TextEntryDialog(None, u'新增模板基本信息:', u'新增框', u'模板名:基本信息:',
                                 wx.OK | wx.CANCEL | wx.TE_MULTILINE)
     if dialog.ShowModal() == wx.ID_OK:
         print "You want to add a new one -> %s" % dialog.GetValue()
     dialog.Destroy()
Ejemplo n.º 3
0
 def OnSavePreset(self, evt):
     d = wx.TextEntryDialog(self, _("Preset name"))
     if d.ShowModal() == wx.ID_OK:
         preset_name = d.GetValue()
         Publisher.sendMessage(_("Save raycasting preset"), preset_name)
Ejemplo n.º 4
0
    def Modifier(self):
        """ Modification d'un type de pièce """
        index = self.listCtrl_Situations.GetFirstSelected()
        if index == -1:
            dlg = wx.MessageDialog(
                self,
                _(u"Vous devez d'abord sélectionner un type de situation sociale à modifier dans la liste."
                  ), "Information", wx.OK | wx.ICON_INFORMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return

        # Avertissement si ce type de situation a déjà été attribué à une personne
        nbreTitulaires = int(
            self.listCtrl_Situations.GetItem(index, 2).GetText())
        if nbreTitulaires != 0:
            message = _(
                u"Avertissement : Ce type de situation sociale a déjà été attribué a "
            ) + str(nbreTitulaires) + _(
                u" personne(s). Toute modification sera donc répercutée en cascade sur toutes les fiches des personnes à qui cette situation sociale a été attribuée. \n\nSouhaitez-vous quand même modifier ce type de situation ?"
            )
            dlg = wx.MessageDialog(
                self, message, "Information",
                wx.YES_NO | wx.NO_DEFAULT | wx.ICON_INFORMATION)
            reponse = dlg.ShowModal()
            if reponse == wx.ID_NO:
                dlg.Destroy()
                return
            else:
                dlg.Destroy()

        varIDsituation = int(
            self.listCtrl_Situations.GetItem(index, 0).GetText())
        varNomSituation = self.listCtrl_Situations.GetItem(index, 1).GetText()

        dlg = wx.TextEntryDialog(
            self,
            _(u"Saisissez le nom du nouveau type de situation sociale :"),
            _(u"Saisie d'un nouveau type de situation sociale"),
            varNomSituation)
        if dlg.ShowModal() == wx.ID_OK:
            varNomSituation = dlg.GetValue()
            dlg.Destroy()
        else:
            dlg.Destroy()
            return

        if varNomSituation == "":
            dlg = wx.MessageDialog(
                self, _(u"Le nom que vous avez saisi n'est pas valide."),
                "Information", wx.OK | wx.ICON_INFORMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return

        # Sauvegarde
        listeDonnees = [
            ("situation", varNomSituation),
        ]

        # Initialisation de la connexion avec la Base de données
        DB = GestionDB.DB()
        DB.ReqMAJ("situations", listeDonnees, "IDsituation", varIDsituation)
        DB.Close()

        # MàJ du ListCtrl
        self.listCtrl_Situations.MAJListeCtrl()
    def browseDir(self, event):
        """
        Show the DirDialog and ask the user to change the directory where machine labels are stored
        """

        fname = str("machinelabels-iter" + str(self.iterationindex) + ".h5")
        self.statusbar.SetStatusText(
            "Looking for a folder to start refining...")
        if self.jump_unlabeled:
            cwd = str(
                auxiliaryfunctions.find_next_unlabeled_folder(
                    self.config_file))
        else:
            cwd = os.path.join(os.getcwd(), "labeled-data")
        #        dlg = wx.FileDialog(self, "Choose the machinelabels file for current iteration.",cwd, "",wildcard=fname,style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
        if platform.system() == "Darwin":
            dlg = wx.FileDialog(
                self,
                "Choose the machinelabels file for current iteration.",
                cwd,
                fname,
                wildcard="(*.h5)|*.h5",
                style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST,
            )
        else:
            dlg = wx.FileDialog(
                self,
                "Choose the machinelabels file for current iteration.",
                cwd,
                "",
                wildcard=fname,
                style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST,
            )

        if dlg.ShowModal() == wx.ID_OK:
            self.data_file = dlg.GetPath()
            self.dir = str(Path(self.data_file).parents[0])
            self.fileName = str(Path(self.data_file).stem)
            self.load.Enable(False)
            self.next.Enable(True)
            self.save.Enable(True)
            self.zoom.Enable(True)
            self.pan.Enable(True)
            self.home.Enable(True)
            self.quit.Enable(True)
            self.lock.Enable(True)
        else:
            dlg.Destroy()
            self.Destroy()
            return
        dlg.Destroy()

        try:
            self.dataname = str(self.data_file)

        except:
            print("No machinelabels file found!")
            self.Destroy()
        self.statusbar.SetStatusText("Working on folder: {}".format(
            os.path.split(str(self.dir))[-1]))
        self.preview = True
        self.iter = 0

        if os.path.isfile(self.dataname):
            self.Dataframe = pd.read_hdf(self.dataname)
            # Overwrite the config-defined individual names
            # with those actually present in the annotated data
            self.individual_names = (self.Dataframe.columns.get_level_values(
                "individuals").unique().to_list())
            conversioncode.guarantee_multiindex_rows(self.Dataframe)
            self.Dataframe.sort_index(inplace=True)
            self.scorer = self.Dataframe.columns.get_level_values(0)[0]

            # bodyParts = self.Dataframe.columns.get_level_values(1)
            # _, idx = np.unique(bodyParts, return_index=True)
            # self.num_joints = len(self.bodyparts)
            # self.bodyparts =  bodyParts[np.sort(idx)]
            self.index = list(self.Dataframe.iloc[:, 0].index)
            # Reading images

            self.img = os.path.join(self.project_path, *self.index[self.iter])
            img_name = Path(self.img).name
            self.norm, self.colorIndex = self.image_panel.getColorIndices(
                self.img, self.bodyparts)
            # Adding Slider and Checkbox

            (
                self.choiceBox,
                self.slider,
                self.checkBox,
                self.visualization_rdb,
            ) = self.choice_panel.addCheckBoxSlider(self.bodyparts, self.file,
                                                    self.markerSize)
            self.slider.Bind(wx.EVT_SLIDER, self.OnSliderScroll)
            self.checkBox.Bind(wx.EVT_CHECKBOX, self.activateSlider)
            self.visualization_rdb.Bind(wx.EVT_RADIOBOX, self.clear_plot)
            self.slider.Enable(False)

            # take into account of all the bodyparts for the colorscheme. Sort the bodyparts to have same order as in the config file
            self.all_bodyparts = np.array(self.multianimalbodyparts +
                                          self.uniquebodyparts)
            _, return_idx = np.unique(self.all_bodyparts, return_index=True)
            self.all_bodyparts = list(self.all_bodyparts[np.sort(return_idx)])

            # Show image
            # Setting axis title:dont want to show the threshold as it is not selected yet.

            (
                self.figure,
                self.axes,
                self.canvas,
                self.toolbar,
                self.ax,
            ) = self.image_panel.drawplot(
                self.img,
                img_name,
                self.iter,
                self.index,
                self.threshold,
                self.colormap,
                self.preview,
            )
            self.axes.callbacks.connect("xlim_changed", self.onZoom)
            self.axes.callbacks.connect("ylim_changed", self.onZoom)

            instruction = wx.MessageBox(
                "1. Enter the likelihood threshold. \n\n2. Each prediction will be shown with a unique color. \n All the data points above the threshold will be marked as circle filled with a unique color. All the data points below the threshold will be marked with a hollow circle. \n\n3. Enable the checkbox to adjust the marker size. \n\n4.  Hover your mouse over data points to see the labels and their likelihood. \n\n5. Left click and drag to move the data points. \n\n6. Middle click on any data point to remove it. Be careful, you cannot undo this step. \n Click once on the zoom button to zoom-in the image.The cursor will become cross, click and drag over a point to zoom in. \n Click on the zoom button again to disable the zooming function and recover the cursor. \n Use pan button to pan across the image while zoomed in. Use home button to go back to the full;default view. \n\n7. When finished click 'Save' to save all the changes. \n\n8. Click OK to continue",
                "User instructions",
                wx.OK | wx.ICON_INFORMATION,
            )

            if instruction == 4:
                """
                If ok is selected then the image is updated with the thresholded value of the likelihood
                """
                textBox = wx.TextEntryDialog(
                    self,
                    "Select the likelihood threshold",
                    caption="Enter the threshold",
                    value="0.1",
                )
                textBox.ShowModal()
                self.threshold = float(textBox.GetValue())
                textBox.Destroy()
                self.img = os.path.join(self.project_path,
                                        *self.index[self.iter])
                img_name = Path(self.img).name
                self.axes.clear()
                self.preview = False
                # self.figure.delaxes(self.figure.axes[1]) # Removes the axes corresponding to the colorbar
                (
                    self.figure,
                    self.axes,
                    self.canvas,
                    self.toolbar,
                    self.ax,
                ) = self.image_panel.drawplot(
                    self.img,
                    img_name,
                    self.iter,
                    self.index,
                    self.threshold,
                    self.colormap,
                    self.preview,
                )
                self.axes.callbacks.connect("xlim_changed", self.onZoom)
                self.axes.callbacks.connect("ylim_changed", self.onZoom)
                MainFrame.plot(self, self.img)
                MainFrame.saveEachImage(self)
            else:
                # self.figure.delaxes(self.figure.axes[1]) # Removes the axes corresponding to the colorbar
                (
                    self.figure,
                    self.axes,
                    self.canvas,
                    self.toolbar,
                    self.ax,
                ) = self.image_panel.drawplot(
                    self.img,
                    img_name,
                    self.iter,
                    self.index,
                    self.threshold,
                    self.colormap,
                    self.preview,
                )
                self.axes.callbacks.connect("xlim_changed", self.onZoom)
                self.axes.callbacks.connect("ylim_changed", self.onZoom)
                MainFrame.plot(self, self.img)
                MainFrame.saveEachImage(self)

        else:
            msg = wx.MessageBox(
                "No Machinelabels file found! Want to retry?",
                "Error!",
                wx.YES_NO | wx.ICON_WARNING,
            )
            if msg == 2:
                self.load.Enable(True)
                self.next.Enable(False)
                self.save.Enable(False)
Ejemplo n.º 6
0
    def startServer(self, e):
        file = open("preferredPort.txt", "r")
        temp = file.readline()

        if temp != '':
            self.port = int(temp)
            file.close()
        else:
            portBox = wx.TextEntryDialog(None, "Start server on which port?",
                                         "Port Selection", '')
            if portBox.ShowModal() == wx.ID_OK:
                self.port = int(portBox.GetValue())

        # SERVER SHIT
        self.host = '127.0.0.1'

        # MAPS ADDRESS TO NAME
        self.clients = {}
        # MAPS ADDRESS TO PORT
        self.addresses = {}
        # MAPS GROUP TO NAMES
        self.groups = {}
        # MAPS ADDRESS TO GROUP NAME
        self.groupchats = {}
        # MAPS CHATROOM NAME TO PASSWORD AND USERS IN CHATROOM
        self.chatRooms = {}
        # MAPS ADDRESS TO CHATROOM NAME
        self.chatRoomsAddr = {}

        self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        success = False

        # ATTEMPTS BINDING TO PORT
        try:
            self.s.bind((self.host, self.port))
            self.log.SetBackgroundColour((148, 255, 106))
            success = True
            self.log.AppendText("SERVER STARTING ON PORT " + str(self.port) +
                                "\n")
        except:
            self.log.AppendText("PORT " + str(self.port) +
                                " IS TAKEN, UNABLE TO START SERVER\n")

        # STARTS SERVER IF PORT IS NOT TAKEN
        if (success):
            self.quitting = False

            # ACTIVATE LISTENING THREAD
            self.s.listen(100)
            self.lT = threading.Thread(target=self.listening)
            self.lT.setDaemon(True)
            self.lT.start()

            # HIDE SERVER (OFF) BUTTON
            self.btnServer.Hide()
            self.preferredButton.Hide()

            # ADD SERVER BUTTON (ON)
            imgServer = wx.Image("rsrcs/serverButton-2.jpg",
                                 wx.BITMAP_TYPE_ANY).Scale(60, 60)
            imgServer = wx.Bitmap(imgServer)
            self.btnServer2 = wx.BitmapButton(self.mainPanel, -1, imgServer,
                                              (20, 130), (60, 60))
            self.btnServer2.Bind(wx.EVT_BUTTON, self.stopServer)

            self.Refresh()
Ejemplo n.º 7
0
	def edit(workplace=None):

		dbcfg = gmCfg.cCfgSQL()

		if workplace is None:
			dlg = wx.TextEntryDialog (
				parent,
				_('Enter a descriptive name for the new workplace:'),
				caption = _('Configuring GNUmed workplaces ...'),
				value = '',
				style = wx.OK | wx.CENTRE
			)
			dlg.ShowModal()
			workplace = dlg.GetValue().strip()
			if workplace == '':
				gmGuiHelpers.gm_show_error(_('Cannot save a new workplace without a name.'), _('Configuring GNUmed workplaces ...'))
				return False
			curr_plugins = []
		else:
			curr_plugins = gmTools.coalesce(dbcfg.get2 (
				option = 'horstspace.notebook.plugin_load_order',
				workplace = workplace,
				bias = 'workplace'
				), []
			)

		msg = _(
			'Pick the plugin(s) to be loaded the next time the client is restarted under the workplace:\n'
			'\n'
			'    [%s]\n'
		) % workplace

		picker = gmListWidgets.cItemPickerDlg (
			parent,
			-1,
			title = _('Configuring workplace plugins ...'),
			msg = msg
		)
		picker.set_columns(['Available plugins'], ['Active plugins'])
		available_plugins = gmPlugin.get_installed_plugins(plugin_dir = 'gui')
		picker.set_choices(available_plugins)
		picker.set_picks(picks = curr_plugins[:])
		btn_pressed = picker.ShowModal()
		if btn_pressed != wx.ID_OK:
			picker.DestroyLater()
			return False

		new_plugins = picker.get_picks()
		picker.DestroyLater()
		if new_plugins == curr_plugins:
			return True

		if new_plugins is None:
			return True

		dbcfg.set (
			option = 'horstspace.notebook.plugin_load_order',
			value = new_plugins,
			workplace = workplace
		)

		return True
Ejemplo n.º 8
0
 def addlocation(self, event):
     box2 = wx.TextEntryDialog(None, 'Enter location')
     if box2.ShowModal() == wx.ID_OK:
         locations.append(box2.GetValue())
Ejemplo n.º 9
0
    def basicGUI(self):

        panel = wx.Panel(self)

        menuBar = wx.MenuBar()

        fileButton = wx.Menu()
        editButton = wx.Menu()

        exitItem = fileButton.Append(wx.ID_EXIT, 'Check', 'checking files...')
        menuBar.Append(fileButton, 'File')
        menuBar.Append(editButton, 'Edit')

        self.SetMenuBar(menuBar)
        self.Bind(wx.EVT_MENU, self.Quit, exitItem)

        nameBox = wx.TextEntryDialog(None, 'What is your name?',
                                     'Welcome User', 'Joy')

        if nameBox.ShowModal() == wx.ID_OK:
            userName = nameBox.GetValue()

        #yesNoBox = wx.MessageDialog(None, 'Do you like this?', 'Question', wx.YES_NO)
        #yesNoAnswer = yesNoBox.ShowModal()
        #yesNoBox.Destroy()

        #if yesNoAnswer == wx.ID_NO:
        #userName = '******'

        chooseOneBox = wx.SingleChoiceDialog(
            None, 'Search for the files to be checked daily',
            'Browse for Folders',
            ['Folder A', 'Folder B', 'Folder C', 'Folder D'])

        if chooseOneBox.ShowModal() == wx.ID_OK:
            folder = chooseOneBox.GetStringSelection()

        wx.TextCtrl(panel, pos=(3, 100), size=(150, 50))

        aweText = wx.StaticText(panel, -1, "You chose Folder...", (3, 3))
        aweText.SetForegroundColour('black')
        aweText.SetBackgroundColour('white')

        rlyAweText = wx.StaticText(
            panel, -1,
            "Choose 'file', then 'check' to execute checking process ",
            (3, 30))
        rlyAweText.SetForegroundColour(folder)
        rlyAweText.SetBackgroundColour('white')

        chooseOneBox = wx.SingleChoiceDialog(
            None, 'Choose the folder to move the files', 'Browse for Folders',
            ['Folder E', 'Folder F', 'Folder G', 'Folder H'])

        if chooseOneBox.ShowModal() == wx.ID_OK:
            folder = chooseOneBox.GetStringSelection()

        wx.TextCtrl(panel, pos=(3, 100), size=(150, 50))

        self.SetTitle('Welcome ' + userName)
        self.Show(True)
Ejemplo n.º 10
0
    def ModifierFichier(self, titre=""):
        """ Modifier un fichier """
        if UTILS_Utilisateurs.VerificationDroitsUtilisateurActuel(
                "fichier_fichier", "modifier") == False:
            return

        if self.mode == "reseau":
            dlg = wx.MessageDialog(
                self,
                _(u"Il est impossible de modifier le nom d'un fichier réseau !"
                  ), _(u"Désolé"), wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return

        # Demande de confirmation 1
        dlg = wx.MessageDialog(
            None,
            _(u"Souhaitez-vous vraiment modifier le nom du fichier '%s' ?") %
            titre, _(u"Modifier un fichier"),
            wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_QUESTION)
        reponse = dlg.ShowModal()
        dlg.Destroy()
        if reponse != wx.ID_YES:
            return

        # Demande le nouveau nom du fichier
        dlg = wx.TextEntryDialog(
            self,
            _(u"Saisissez un nouveau nom pour le fichier '%s' :") % titre,
            _(u"Modifier le nom"), titre)
        if dlg.ShowModal() == wx.ID_OK:
            nouveauTitre = dlg.GetValue()
            dlg.Destroy()
        else:
            dlg.Destroy()
            return

        if nouveauTitre == "":
            dlg = wx.MessageDialog(
                self, _(u"Le nom que vous avez saisi ne semble pas valide !"),
                _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return

        # Demande de confirmation 2
        dlg = wx.MessageDialog(
            None,
            _(u"Vous êtes vraiment sûr de vouloir changer le nom du fichier '%s' en '%s' ?"
              ) % (titre, nouveauTitre), _(u"Modifier un fichier"),
            wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_EXCLAMATION)
        reponse = dlg.ShowModal()
        dlg.Destroy()
        if reponse != wx.ID_YES:
            return

        # Modifier un fichier local
        for suffixe in ("DATA", "DOCUMENTS", "PHOTOS"):
            try:
                source = UTILS_Fichiers.GetRepData(u"%s_%s.dat" %
                                                   (titre, suffixe))
                destination = UTILS_Fichiers.GetRepData(
                    u"%s_%s.dat" % (nouveauTitre, suffixe))
                os.rename(source, destination)
            except Exception, err:
                print suffixe, "Erreur dans le renommage de fichier : ", err
Ejemplo n.º 11
0
    def OnGraph(self, event):
        """ Graph button has been pressed.
		"""

        activePage = self.notebook.GetSelection()
        sheet = self.notebook.GetPage(activePage)
        title = self.notebook.GetPageText(activePage)

        ### selected rows with mouse but on label colonn
        #selected_rows = sheet.GetSelectedRows()

        ### really selected cells with mouse
        a = sheet.GetSelectionBlockTopLeft()
        b = sheet.GetSelectionBlockBottomRight()

        ### selected rows with mouse
        try:
            i = a[0][0]
            j = b[0][0]
        ### selected all rows
        except IndexError:
            i = 0
            j = sheet.GetNumberRows()

        selected_rows = range(i, j)

        nbc = xrange(sheet.GetNumberCols())
        nbr = xrange(
            sheet.GetNumberRows()) if selected_rows == [] else selected_rows

        data = []
        select = -1
        for i in nbr:
            v = sheet.GetCellValue(i, sheet.GetNumberCols() - 1)

            if '<<' in v or '>>' in v:
                s = sheet.GetCellValue(i,
                                       sheet.GetNumberCols() - 1).replace(
                                           '<< ',
                                           '').replace('<<',
                                                       '').replace('>>', '')
            else:
                s = "value = %s; time = %s" % (v, sheet.GetCellValue(i, 0))

            ### globals containt the time and value variables after exec of the statement
            exec(str(s), globals())

            ### if value is a list, we must choose an index to plot amoung the values of the list
            if isinstance(value, list):
                if select == -1:
                    dlg = wx.TextEntryDialog(
                        self,
                        _('Choose one index between [%d-%d] to plot into the list of values.'
                          ) % (0, len(value) - 1),
                        _('Plotting Manager'),
                        value="0")
                    if dlg.ShowModal() == wx.ID_OK:
                        select = int(dlg.GetValue())
                        dlg.Destroy()
                    else:
                        dlg.Destroy()
                        break

                ### choice is digit else we break
                if select in range(
                        0,
                        len(value) - 1) and not isinstance(value[select], str):
                    data.append((time, float(value[select])))
                else:
                    wx.MessageBox(_('Value to plot must be digit!'),
                                  _('Warning'), wx.OK | wx.ICON_WARNING)
                    break

            ### first if int is digit or if float is digit
            else:
                v = str(format(value, 'f')).lstrip('-')
                if v.isdigit() or v.replace(".", "", 1).isdigit():
                    data.append((time, float(value)))
                else:
                    wx.MessageBox(
                        _('Type of data should be float or int : %s') %
                        str(value), _('Info'))
                    break

        if data != []:
            frame = StaticPlot(self, wx.ID_ANY, title, data)
            frame.Center()
            frame.Show()
Ejemplo n.º 12
0
 def onMemorizeTrace(self, evt):
     dlg = wx.TextEntryDialog(self, "Enter name of trace", "Enter name")
     dlg.ShowModal()
     x = self.traceMemory[self.widget.name].x
     y = self.traceMemory[self.widget.name].y
     self.storeTraceInMem(Trace(x, y), dlg.GetValue())
Ejemplo n.º 13
0
 def onNewVerticalMarker(self, evt):
     dlg = wx.TextEntryDialog(self, "Enter name of marker", "Enter name")
     dlg.ShowModal()
     self.vMarkers[dlg.GetValue()] = self.popupPoint[0]
     print self.vMarkers
Ejemplo n.º 14
0
    def nameset(self,e):
        widget = self._lvset_frame.context_object
        self._message.SetLabel(widget.GetLabel())
        
        try:
            tooltip = widget.GetToolTip().GetTip()
        except:
            tooltip = ""
        
        try:
            found = self.findwidget(widget)
        except:
            self._message.SetLabel("error during find")
            
        if found is None:
            self._message.SetLabel("ERROR: set not found")
            return
        else:
            self._message.SetLabel("set found %d"%len(self._layersetsaved))
        # Ask user for set name
        initname = "Hello"
        if found[3:4][0] is not None:
            self._message.SetLabel("1")
            initname = found[3:4][0]
            self._message.SetLabel("2")
        else:
            self._message.SetLabel("3")
            count = 1
            while os.path.exists(os.path.join(savepath,"ViewSet "+str(count))):
                count += 1
            self._message.SetLabel("4")
            initname = "ViewSet "+str(count)
        self._message.SetLabel("5")
        try:
            dlg = wx.TextEntryDialog(self._lvset_frame, "Enter new set name", defaultValue=initname)
            result = dlg.ShowModal()
        except Exception as e:
            self._message.SetLabel("E! "+str(initname))
            result = None
            return
        
        # self._message.SetLabel("6")
        # self._message.SetLabel("7")
        if result != wx.ID_OK:
            self._message.SetLabel("Cancelled (%s)"%str(result))
            return
        self._message.SetLabel("8")
        new_name = dlg.GetValue()
        if filter(lambda x:x.name==new_name,self._layersetsaved):
            self._message.SetLabel("Already exists")
            return
        dlg.Destroy()

        try:
            if found[3:4][0] is None: # test to see if there's a fourth element (i.e. name)
            #if not found[3:4]: # test to see if there's a fourth element (i.e. name)
                # this is a stack, so save and name it.
                #new_name = str(len(self._layersetsaved))
                self._message.SetLabel("new name %s"%new_name)
                if not os.path.exists(savepath):
                    os.makedirs(savepath)
                    self._message.SetLabel('created ~/kicad/viewsets')
                self._message.SetLabel("saving to %s"%new_name)
                new_path = os.path.join(savepath, new_name)
                with open(new_path,'w') as f:
                    #print(dir(found))
                    layers=found.layers
                    self._message.SetLabel("L %s"%new_name)
                    items=found.items
                    self._message.SetLabel("I %s"%new_name)
                    if layers is not None:
                        self._message.SetLabel("writing %s, %s"%(new_name,str(layers)))
                        for layer in self.getnamefromlayers(layers):
                            f.write('layer,%s,%d\n'%(layer,1))
                        self._message.SetLabel("wrote layers")
                    if items is not None:
                        rname = "{0:b}".format(items)
                        f.write('render,%s,%d\n'%(rname,1))
                        self._message.SetLabel("wrote items")

                new_widget = self.get_viewset_widget(self._nameparent,new_name,tooltip) # names
                new_element = Element(found.layers,found.items,new_widget,new_name,new_path)
                self._message.SetLabel("created element")

                self._layersetsaved.append(new_element)    
                self._message.SetLabel("appended")
            else:
                self._message.SetLabel("new name %s"%new_name)
                # found contains the element to rename
                widget = found.widget
                old_name = found.name
                old_filepath = found.filepath
                new_filepath = os.path.join(savepath,new_name)
                
                # rename the file
                os.rename(old_filepath,new_filepath)
                # rename the widget
                widget.SetLabel(new_name)
                # replace the element in the Named ViewSet List
                i = self._layersetsaved.index(found)
                self._layersetsaved[i] = (found.layers,found.items,widget,new_name,new_filepath)
            self._message.SetLabel("Saved %s"%new_name)
        except Exception as e:
            self._message.SetLabel("ERROR "+self._message.GetLabel())
            etext = str(e)
            wx.MessageDialog(widget,etext,style=wx.OK).ShowModal()
Ejemplo n.º 15
0
	def edit_old(workplace=None):

		available_plugins = gmPlugin.get_installed_plugins(plugin_dir='gui')

		dbcfg = gmCfg.cCfgSQL()

		if workplace is None:
			dlg = wx.TextEntryDialog (
				parent,
				_('Enter a descriptive name for the new workplace:'),
				caption = _('Configuring GNUmed workplaces ...'),
				value = '',
				style = wx.OK | wx.CENTRE
			)
			dlg.ShowModal()
			workplace = dlg.GetValue().strip()
			if workplace == '':
				gmGuiHelpers.gm_show_error(_('Cannot save a new workplace without a name.'), _('Configuring GNUmed workplaces ...'))
				return False
			curr_plugins = []
			choices = available_plugins
		else:
			curr_plugins = gmTools.coalesce(dbcfg.get2 (
				option = 'horstspace.notebook.plugin_load_order',
				workplace = workplace,
				bias = 'workplace'
				), []
			)
			choices = curr_plugins[:]
			for p in available_plugins:
				if p not in choices:
					choices.append(p)

		sels = range(len(curr_plugins))
		new_plugins = gmListWidgets.get_choices_from_list (
			parent = parent,
			msg = _(
				'\n'
				'Select the plugin(s) to be loaded the next time\n'
				'the client is restarted under the workplace:\n'
				'\n'
				' [%s]'
				'\n'
			) % workplace,
			caption = _('Configuring GNUmed workplaces ...'),
			choices = choices,
			selections = sels,
			columns = [_('Plugins')],
			single_selection = False
		)

		if new_plugins == curr_plugins:
			return True

		if new_plugins is None:
			return True

		dbcfg.set (
			option = 'horstspace.notebook.plugin_load_order',
			value = new_plugins,
			workplace = workplace
		)

		return True
Ejemplo n.º 16
0
    def browseDir(self, event):
        """
        Show the DirDialog and ask the user to change the directory where machine labels are stored
        """

        fname = str('machinelabels-iter' + str(self.iterationindex) + '.h5')
        self.statusbar.SetStatusText(
            "Looking for a folder to start refining...")
        cwd = os.path.join(os.getcwd(), 'labeled-data')
        dlg = wx.FileDialog(
            self,
            "Choose the machinelabels file for current iteration.",
            cwd,
            "",
            wildcard=fname,
            style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)

        if dlg.ShowModal() == wx.ID_OK:
            self.data_file = dlg.GetPath()
            self.dir = str(Path(self.data_file).parents[0])
            self.fileName = str(Path(self.data_file).stem)
            self.load.Enable(False)
            self.next.Enable(True)
            self.save.Enable(True)
            self.zoom.Enable(True)
            self.pan.Enable(True)
            self.home.Enable(True)
            self.quit.Enable(True)
        else:
            dlg.Destroy()
            self.Destroy()
        dlg.Destroy()

        try:
            self.dataname = str(self.data_file)

        except:
            print("No machinelabels file found!")
            self.Destroy()
        self.statusbar.SetStatusText('Working on folder: {}'.format(
            os.path.split(str(self.dir))[-1]))
        self.preview = True
        self.iter = 0

        if os.path.isfile(self.dataname):
            self.Dataframe = pd.read_hdf(self.dataname, 'df_with_missing')
            self.Dataframe.sort_index(inplace=True)
            self.scorer = self.Dataframe.columns.get_level_values(0)[0]

            # bodyParts = self.Dataframe.columns.get_level_values(1)
            # _, idx = np.unique(bodyParts, return_index=True)
            # self.num_joints = len(self.bodyparts)
            # self.bodyparts =  bodyParts[np.sort(idx)]
            self.index = list(self.Dataframe.iloc[:, 0].index)
            # Reading images

            self.img = os.path.join(self.project_path, self.index[self.iter])
            img_name = Path(self.img).name
            self.norm, self.colorIndex = self.image_panel.getColorIndices(
                self.img, self.bodyparts)
            # Adding Slider and Checkbox

            self.choiceBox, self.slider, self.checkBox = self.choice_panel.addCheckBoxSlider(
                self.bodyparts, self.file, self.markerSize)
            self.slider.Bind(wx.EVT_SLIDER, self.OnSliderScroll)
            self.checkBox.Bind(wx.EVT_CHECKBOX, self.activateSlider)
            self.slider.Enable(False)
            # Show image
            # Setting axis title:dont want to show the threshold as it is not selected yet.
            self.figure, self.axes, self.canvas, self.toolbar = self.image_panel.drawplot(
                self.img, img_name, self.iter, self.index, self.threshold,
                self.bodyparts, self.colormap, self.preview)

            instruction = wx.MessageBox(
                '1. Enter the likelihood threshold. \n\n2. Each prediction will be shown with a unique color. \n All the data points above the threshold will be marked as circle filled with a unique color. All the data points below the threshold will be marked with a hollow circle. \n\n3. Enable the checkbox to adjust the marker size. \n\n4.  Hover your mouse over data points to see the labels and their likelihood. \n\n5. Left click and drag to move the data points. \n\n6. Right click on any data point to remove it. Be careful, you cannot undo this step. \n Click once on the zoom button to zoom-in the image.The cursor will become cross, click and drag over a point to zoom in. \n Click on the zoom button again to disable the zooming function and recover the cursor. \n Use pan button to pan across the image while zoomed in. Use home button to go back to the full;default view. \n\n7. When finished click \'Save\' to save all the changes. \n\n8. Click OK to continue',
                'User instructions', wx.OK | wx.ICON_INFORMATION)

            if instruction == 4:
                """
                If ok is selected then the image is updated with the thresholded value of the likelihood
                """
                textBox = wx.TextEntryDialog(self,
                                             "Select the likelihood threshold",
                                             caption="Enter the threshold",
                                             value="0.1")
                textBox.ShowModal()
                self.threshold = float(textBox.GetValue())
                textBox.Destroy()
                self.img = os.path.join(self.project_path,
                                        self.index[self.iter])
                img_name = Path(self.img).name
                self.axes.clear()
                self.preview = False
                self.figure, self.axes, self.canvas, self.toolbar = self.image_panel.drawplot(
                    self.img, img_name, self.iter, self.index, self.threshold,
                    self.bodyparts, self.colormap, self.preview)
                MainFrame.plot(self, self.img)
                MainFrame.saveEachImage(self)
            else:
                self.figure, self.axes, self.canvas, self.toolbar = self.image_panel.drawplot(
                    self.img, img_name, self.iter, self.index, self.threshold,
                    self.bodyparts, self.colormap, self.preview)
                MainFrame.plot(self, self.img)
                MainFrame.saveEachImage(self)

        else:
            msg = wx.MessageBox('No Machinelabels file found! Want to retry?',
                                'Error!', wx.YES_NO | wx.ICON_WARNING)
            if msg == 2:
                self.load.Enable(True)
                self.next.Enable(False)
                self.save.Enable(False)
Ejemplo n.º 17
0
 def addajective(self, event):
     box1 = wx.TextEntryDialog(None, 'Enter adjective')
     if box1.ShowModal() == wx.ID_OK:
         adjectives.append(box1.GetValue())