Exemplo n.º 1
1
 def msg(self):
      #后面四个数字的作用依次是 初始值 最小值 最大值 小数点后位数
     doubleNum,ok1 = QInputDialog.getDouble(self, "标题","计数:", 37.56, -10000, 10000, 2)
      #后面四个数字的作用依次是 初始值 最小值 最大值 步幅
     intNum,ok2 = QInputDialog.getInt(self, "标题","计数:", 37, -10000, 10000, 2)
      #第三个参数可选 有一般显示 (QLineEdit.Normal)、密碼显示( QLineEdit. Password)与不回应文字输入( QLineEdit. NoEcho)
     stringNum,ok3 = QInputDialog.getText(self, "标题","姓名:",QLineEdit.Normal, "王尼玛")
      #1为默认选中选项目,True/False  列表框是否可编辑。
     items = ["Spring", "Summer", "Fall", "Winter"]
     item, ok4 = QInputDialog.getItem(self, "标题","Season:", items, 1, True)
     text, ok5 = QInputDialog.getMultiLineText(self, "标题", "Address:", "John Doe\nFreedom Street")
Exemplo n.º 2
0
 def askPenWidth(self) -> None:
     # noinspection PyCallByClass, PyTypeChecker
     res = QInputDialog.getDouble(self, 'Change pen width',
                                  'Enter new pen width:',
                                  self.precision, -10000, 10000, 3)
     if res[1]:
         self.precision = res[0]
Exemplo n.º 3
0
 def on_bTest_clicked(self):
     """
     Private method to test the selected options.
     """
     if self.rText.isChecked():
         if self.rEchoNormal.isChecked():
             echomode = QLineEdit.Normal
         elif self.rEchoNoEcho.isChecked():
             echomode = QLineEdit.NoEcho
         else:
             echomode = QLineEdit.Password
         QInputDialog.getText(
             None,
             self.eCaption.text(),
             self.eLabel.text(),
             echomode,
             self.eTextDefault.text())
     elif self.rInteger.isChecked():
         QInputDialog.getInt(
             None,
             self.eCaption.text(),
             self.eLabel.text(),
             self.sIntDefault.value(),
             self.sIntFrom.value(),
             self.sIntTo.value(),
             self.sIntStep.value())
     elif self.rDouble.isChecked():
         try:
             doubleDefault = float(self.eDoubleDefault.text())
         except ValueError:
             doubleDefault = 0
         try:
             doubleFrom = float(self.eDoubleFrom.text())
         except ValueError:
             doubleFrom = -2147483647
         try:
             doubleTo = float(self.eDoubleTo.text())
         except ValueError:
             doubleTo = 2147483647
         QInputDialog.getDouble(
             None,
             self.eCaption.text(),
             self.eLabel.text(),
             doubleDefault,
             doubleFrom,
             doubleTo,
             self.sDoubleDecimals.value())
Exemplo n.º 4
0
    def new_item_edit_options(self, new):
        """Edit the selected item option with custom dialog."""

        if new:
            selected = ItemOptionWidget("", None)
        else:
            selected = self.ui.variant.currentItem()

        # TODO: need a better way to lay this out. it's going to get big and messy fast

        # this is for the qinputdialog stuff. can't set signals on them
        generic = False
        if new:
            # needs to be here or new opts get detected as string (?)
            dialog = ItemEditOptions(self.dialog, selected.option[0], selected.option[1])
            def get_option():
                data = dialog.ui.options.toPlainText()
                return dialog.ui.name.text(), json.loads(data)
        #elif selected.option[0] in ["inventoryIcon", "image", "largeImage"]:
        #    dialog = ImageBrowser(self.dialog, self.assets)
        #    def get_option():
        #        return selected.option[0], dialog.get_key()
        elif type(self.item["parameters"][selected.option[0]]) is str:
            generic = True
            text, ok = QInputDialog.getText(self.dialog, "Edit Text", selected.option[0],
                                            text=self.item["parameters"][selected.option[0]])
            if ok:
                self.item["parameters"][selected.option[0]] = text
        elif type(self.item["parameters"][selected.option[0]]) is int:
            generic = True
            num, ok = QInputDialog.getInt(self.dialog, "Edit Integer", selected.option[0],
                                          self.item["parameters"][selected.option[0]])
            if ok:
                self.item["parameters"][selected.option[0]] = num
        elif type(self.item["parameters"][selected.option[0]]) is float:
            generic = True
            num, ok = QInputDialog.getDouble(self.dialog, "Edit Double", selected.option[0],
                                             self.item["parameters"][selected.option[0]], decimals=2)
            if ok:
                self.item["parameters"][selected.option[0]] = num
        elif type(self.item["parameters"][selected.option[0]]) is bool:
            generic = True
            self.item["parameters"][selected.option[0]] = not self.item["parameters"][selected.option[0]]
        else:
            dialog = ItemEditOptions(self.dialog, selected.option[0], selected.option[1])
            def get_option():
                data = dialog.ui.options.toPlainText()
                return dialog.ui.name.text(), json.loads(data)

        def save():
            new_option = get_option()
            self.item["parameters"][new_option[0]] = new_option[1]

        if not generic:
            dialog.dialog.accepted.connect(save)
            dialog.dialog.exec()

        self.populate_options()
        self.update_item_info(self.item["name"], self.item["parameters"])
Exemplo n.º 5
0
 def mean_blur(self):
     if self.image.checkIfEmpty():
         ratio, pressed = QInputDialog.getDouble(self,
                                                 "Set filter strength",
                                                 "Value(1,10):", 1, 1, 10,
                                                 2)
         if pressed:
             self.image.mean_blur(ratio)
             self.refresh()
Exemplo n.º 6
0
 def linearContrastOwn(self):
     if self.image.checkIfEmpty():
         ratio, pressed = QInputDialog.getDouble(self,
                                                 "Set contrast procentage",
                                                 "Value(-255 to 255):", 0,
                                                 -255, 255, 2)
         if pressed:
             self.image.linearcontrastOwn(ratio)
             self.refresh()
Exemplo n.º 7
0
 def logContrastOwn(self):
     if self.image.checkIfEmpty():
         ratio, pressed = QInputDialog.getDouble(self,
                                                 "Set contrast procentage",
                                                 "Value(0 to 255):", 128, 0,
                                                 255, 0)
         if pressed:
             self.image.logcontrastOwn(1 + ratio / 3)
             self.refresh()
Exemplo n.º 8
0
 def powerContrastOwn(self):
     if self.image.checkIfEmpty():
         ratio, pressed = QInputDialog.getDouble(self,
                                                 "Set contrast procentage",
                                                 "Value(0 to 200):", 100, 0,
                                                 200, 0)
         if pressed:
             self.image.powercontrastOwn(ratio)
             self.refresh()
Exemplo n.º 9
0
 def lightOwn(self):
     if self.image.checkIfEmpty():
         ratio, pressed = QInputDialog.getDouble(self,
                                                 "Set light procentage",
                                                 "Value(0 to 200):", 100, 0,
                                                 200, 0)
         if pressed:
             self.image.lightOwn(ratio / 100)
             self.refresh()
Exemplo n.º 10
0
 def ifThresh(self, mini, maxi):
     buttonReply = QMessageBox.question(
         self, '',
         "Use {0:.3} and {1:.3} as min and max threshold?\n Cancel to not use threshold"
         .format(mini, maxi),
         QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel,
         QMessageBox.Yes)
     if buttonReply == QMessageBox.Yes:
         return mini, maxi, True
     if buttonReply == QMessageBox.No:
         d, okPressed = QInputDialog.getDouble(self, "", "Minimun value:",
                                               mini, 0, 100, 3)
         e, okPressed = QInputDialog.getDouble(self, "", "Maximun value:",
                                               maxi, 0, 100, 3)
         if okPressed:
             return d, e, True
     if buttonReply == QMessageBox.Cancel:
         return mini, maxi, False
Exemplo n.º 11
0
def ts_change_width():
    global ts_line_width
    value, accepted = QInputDialog.getDouble(mw, "Touch Screen",
                                             "Enter the width:", ts_line_width)
    if accepted:
        ts_line_width = value
        execute_js("line_width = '" + str(ts_line_width) +
                   "'; update_pen_settings()")
        ts_refresh()
Exemplo n.º 12
0
 def AddPoint(self,x,y):
     self.Main.iface.mapCanvas().unsetMapTool(self.AddPointMapTool)
     Point = QgsPointXY(x,y)
     pos = self.player.position()
     if self.player.state() == QMediaPlayer.PlayingState:
         self.player.pause()
     a = self.DBLayer.name()
     last_desc = '///'
     LayerName =str(a)
     last_desc2 = LayerName + ' Point N '
     directory = str(self.DB.split('.')[0])+'_Image/'
     if not os.path.exists(directory):
         os.makedirs(directory)
     fc = int(self.DBLayer.featureCount())
     self.ExtractSingleFrameOnTime(pos,directory+LayerName+'_'+str(fc)+'_.jpg')
     fields = self.DBLayer.fields()
     attributes = []
     lat,lon = Point.y(), Point.x()
     for field in fields:
         a = str(field.name())
         b = str(field.typeName())
         if a == 'id':
             fcnr = fc
             attributes.append(fcnr)  
         elif a == 'Lon(WGS84)':
             attributes.append(str(lon))                       
         elif a == 'Lat(WGS84)':
             attributes.append(str(lat))               
         elif a == 'Image link':
             attributes.append(str(directory+LayerName+'_'+str(fc)+'_.jpg'))                   
         else:                    
             if b == 'String':      
                 (a,ok) = QInputDialog.getText(
                                               self.Main.iface.mainWindow(), 
                                               "Attributes",
                                               a + ' = String',
                                               QLineEdit.Normal)
                 attributes.append(a)               
             elif b == 'Real':                    
                 (a,ok) = QInputDialog.getDouble(
                                                 self.Main.iface.mainWindow(), 
                                                 "Attributes",
                                                 a + ' = Real', decimals = 10)
                 attributes.append(a)
             elif b == 'Integer64':                    
                 (a,ok) = QInputDialog.getInt(
                                              self.Main.iface.mainWindow(), 
                                              "Attributes",
                                              a + ' = Integer')
                 attributes.append(a)                    
     feature = QgsFeature()
     feature.setGeometry(QgsGeometry.fromPoint(Point))
     feature.setAttributes(attributes)
     self.DBLayer.startEditing()
     self.DBLayer.addFeature(feature)
     self.DBLayer.commitChanges()    
     self.DBLayer.triggerRepaint()
Exemplo n.º 13
0
def ts_change_opacity():
    global ts_opacity
    value, accepted = QInputDialog.getDouble(
        mw, "Touch Screen",
        "Enter the opacity (100 = transparent, 0 = opaque):", 100 * ts_opacity,
        0, 100, 2)
    if accepted:
        ts_opacity = value / 100
        execute_js("canvas.style.opacity = " + str(ts_opacity))
        ts_refresh()
Exemplo n.º 14
0
    def complete(self):
        if isinstance(self.new_data, dict):
            new_data = self.new_data
        elif self.new_data is None:
            new_data = {}

            ok = False
            while not ok:
                N, ok = QInputDialog.getInt(
                    self.parent(), 'Parameters',
                    'How many items in task data? (int)')

            for i in range(N):
                ok = False
                while not ok:
                    label, ok = QInputDialog.getText(
                        self.parent(), 'Parameters',
                        'Enter the name of item {}'.format(i))
                ok = False
                while not ok:
                    val, ok = QInputDialog.getDouble(
                        self.parent(), 'Parameters',
                        "Enter the values for key '{}'".format(label))
                new_data[label] = val

        elif isinstance(self.new_data, list) and all(
            [isinstance(el, str) for el in self.new_data]):
            new_data = {}
            for label in self.new_data:
                ok = False
                while not ok:
                    val, ok = QInputDialog.getDouble(
                        self.parent(), 'Parameters',
                        "Enter the values for key '{}'".format(label))
                new_data[label] = val

        else:
            #             print(self.new_data)
            #             print(type(self.new_data))
            print('error: taskData is not a dict')
            return
        print(new_data)
        self.setData(new_data)
Exemplo n.º 15
0
 def set_temperature(self):
     nowTemp = self.qtab.qclayers.temperature
     newTemp, buttonResponse = QInputDialog.getDouble(
         self,
         'ErwinJr2 Input Temperature',
         'Set Temperature',
         value=nowTemp,
         min=0)
     if buttonResponse:
         self.qtab.set_temperature(newTemp)
Exemplo n.º 16
0
 def ReadSeconds(self):
     seconds, ok = QInputDialog.getDouble(
         self, 'Seconds Between Readings',
         "Enter the seconds between readings", 4, 0.1, 20, 1)
     if ok:
         self.readings = seconds
     self.btn_seconds.setText("Seconds Between Readings: " +
                              str(self.readings))
     self.statusBar.showMessage("Seconds Between Readings Changed to " +
                                str(self.readings))
Exemplo n.º 17
0
 def callback():
     d, ok = QInputDialog.getDouble(self,
                                    self.instr_params[ii].gui_name,
                                    self.instr_params[ii].gui_name,
                                    self.instr_params[ii].value)
     if ok:
         self.instr_params[ii].update(d)
         self.param_labels[ii].setText("%s" %
                                       str(self.instr_params[ii]))
         self.send_params()
Exemplo n.º 18
0
 def msg(self):
     doublenum, ok1 = QInputDialog.getDouble(self, "", "", 37.56, -1000,
                                             1000, 2)
     print(doublenum, ok1)
     stringnum, ok3 = QInputDialog.getText(self, "标题", "姓名",
                                           QLineEdit.Normal, "王尼玛")
     print(stringnum, ok3)
     items = ['春', '夏', '秋', '冬']
     item, ok4 = QInputDialog.getItem(self, "标题", "season", items, 1, True)
     print(item, ok4)
Exemplo n.º 19
0
    def gaussian_filter_clicked(self):
        sigma, _ = QInputDialog.getDouble(self, "Select sigma (standard deviation)", "sigma", 1)
        img_cpy = self.image.copy()

        channels = img_cpy.image_element.split()
        for channel in channels:
            op.channel_gaussian_window(channel, sigma)
        img_cpy.set_pillow_image(Image.merge(img_cpy.image_element.mode, channels))

        self.show_result(img_cpy)
Exemplo n.º 20
0
 def c_PEcu_ore(self):
     nPE = len(PuntoExtraccion._registry) - 1
     sPE, ok = QInputDialog.getInt(self, "Gopher Underground",
                                   "Seleccione el Punto de Extraccion: ", 0,
                                   0, nPE, 1)
     if ok:
         string = "Nuevo valor de ley de cobre (%):"
         new, ok = QInputDialog.getDouble(self, "Gopher Underground",
                                          string, 0.5, 0, 100, 2)
         self.PEdict[sPE].cu_ore = new
	def update_weight(self):
		new_weight, ok = QInputDialog.getDouble(self.page(), "Update weight", "Enter your new weight", 65, 60, 80)

		if ok:
			self.data.append(new_weight)
			self._user_model.update_weight(self._user, new_weight)
			self._basic_goal_progress_model.addBasicProgress(self._user, new_weight, date.today())
			self.parent.update()

			display_message('Weight added successfully', f'Good work! You are now {new_weight} kg', False)
Exemplo n.º 22
0
 def add_trip(self):
     current_date = datetime.datetime.now().strftime("%d.%m.%Y")
     trip, ok_pressed = QInputDialog.getDouble(self, "Lisää matka",
                                               "Anna matka kilometreinä", 0,
                                               0.1, 1000, 1)
     if ok_pressed:
         trip_to_file(trip, current_date)
         self.update_goalinfo()
         QMessageBox.information(
             self, "Lisääminen onnistui",
             f"Lisättiin matka: {current_date}: {trip} km", QMessageBox.Ok)
Exemplo n.º 23
0
 def changeExp(self):
     exposure,ok = QInputDialog.getDouble(self,
                                          "Input dialog","Enter exposure (s)", self._imager._exposure, 0, 10, 3)
     liveState=self._live_checkbox.checkState
     if ok:
         self._imager._exposure = exposure
         if(liveState == Qt.Checked):
             self._imager.disable()
         self._imager._client.set_exposure_time(exposure)
         if(liveState == Qt.Checked):
             self._imager.enable()
Exemplo n.º 24
0
 def msg(self):
     # 后面四个数字的作用依次是 初始值 最小值 最大值 小数点后位数
     doubleNum, ok1 = QInputDialog.getDouble(self, "标题", "计数:", 37.56, -10000, 10000, 2)
     # 后面四个数字的作用依次是 初始值 最小值 最大值 步幅
     intNum, ok2 = QInputDialog.getInt(self, "标题", "计数:", 37, -10000, 10000, 2)
     # 第三个参数可选 有一般显示 (QLineEdit.Normal)、密碼显示( QLineEdit. Password)与不回应文字输入( QLineEdit. NoEcho)
     stringNum, ok3 = QInputDialog.getText(self, "标题", "姓名:", QLineEdit.Normal, "王尼玛")
     # 1为默认选中选项目,True/False  列表框是否可编辑。
     items = ["Spring", "Summer", "Fall", "Winter"]
     item, ok4 = QInputDialog.getItem(self, "标题", "Season:", items, 1, True)
     text, ok5 = QInputDialog.getMultiLineText(self, "标题", "Address:", "John Doe\nFreedom Street")
Exemplo n.º 25
0
 def on_qPushButton16_clicked(self):
     dlgTitle = "输入浮点数对话框"
     txtLabel = "输入一个浮点数"
     defaultValue = 3.65
     minValue = 0
     maxValue = 10000
     decimals = 2
     inputValue, OK = QInputDialog.getDouble(self, dlgTitle, txtLabel, defaultValue, minValue, maxValue, decimals)
     if OK:
         text = "输入了一个浮点数:%.2f" % inputValue
         self.ui.qPlainTextEdit.appendPlainText(text)
Exemplo n.º 26
0
 def on_actBar_ChangeValue_triggered(self):
     position = self.series.selectedBar()
     if position.x() < 0 or position.y() < 0:
         return  #必须加此判断
     bar = self.dataProxy.itemAt(position)  #QBarDataItem
     value = bar.value()
     newValue, OK = QInputDialog.getDouble(self, "输入数值", "更改棒柱数值", value, 0,
                                           50, 1)
     if OK:
         bar.setValue(newValue)
         self.dataProxy.setItem(position, bar)
Exemplo n.º 27
0
 def setTimeOffset(self):
     offset, okpressed = QInputDialog.getDouble(
         self,
         'Video time offset',
         'Offset video time position (seconds)',
         value=self.video_time_offset)
     if okpressed:
         self.video_time_offset = offset
         current_position = self.current_time_range[
             0] + self.last_position / 1000
         self.setGlobalPosition(0)
         self.setGlobalPosition(current_position)
Exemplo n.º 28
0
 def on_setMaxYAction_triggered(self):
     (graphY, ok) = QInputDialog.getDouble(
         self,
         self.tr('Set Origin - Y'),
         self.tr('Set the maximal value of Y'),
         self.DEFAULT_VALUE,
         self.MIN_VALUE,
         self.MAX_VALUE,
         self.DIGITS)
     if ok:
         (x, y) = self.pos
         self.setMaxY(y, graphY)
Exemplo n.º 29
0
 def set_Tth(self):
     mca = self.mca
     calibration = copy.deepcopy(mca.get_calibration()[0])
     tth = calibration.two_theta
     val, ok = QInputDialog.getDouble(
         self.widget, "Manual 2theta setting",
         "Current 2theta = " + '%.4f' % (tth) +
         "\nEnter new 2theta: \n(Note: calibrated 2theta value will be updated)",
         tth, 0, 180, 4)
     if ok:
         calibration.two_theta = val
         mca.set_calibration([calibration])
Exemplo n.º 30
0
    def hough_transform_circunference_clicked(self):
        img = self.image.copy()
        h, w = img.channels[0].shape

        xLowerBound = 0
        xUpperBound = w
        xStep = 20

        yLowerBound = 0
        yUpperBound = h
        yStep = 20

        rLowerBound = 10
        rUpperBound = min(w, h)
        rStep = 20

        winnerCount = 5

        epsilon = 10.0

        xLowerBound, _ = QInputDialog.getInt(self, "X lower bound", "Input value", xLowerBound)
        xUpperBound, _ = QInputDialog.getInt(self, "X upper bound", "Input value", xUpperBound)
        xStep, _ = QInputDialog.getInt(self, "X interval count", "Input value", xStep)

        yLowerBound, _ = QInputDialog.getInt(self, "Y lower bound", "Input value", yLowerBound)
        yUpperBound, _ = QInputDialog.getInt(self, "Y upper bound", "Input value", yUpperBound)
        yStep, _ = QInputDialog.getInt(self, "Y interval count", "Input value", yStep)

        rLowerBound, _ = QInputDialog.getInt(self, "R lower bound", "Input value", rLowerBound)
        rUpperBound, _ = QInputDialog.getInt(self, "R upper bound", "Input value", rUpperBound)
        rStep, _ = QInputDialog.getInt(self, "R interval count", "Input value", rStep)

        winnerCount, _ = QInputDialog.getInt(self, "Winner number", "Input value", winnerCount)

        epsilon, _ = QInputDialog.getDouble(self, "Epsilon", "Input value", epsilon)

        img = self.image.copy()

        # 30 30 30 11 / 8 (solo)
        winners = bd.hough_transform_circunference(img.channels[0], xLowerBound, xUpperBound, xStep, yLowerBound,
                                                   yUpperBound, yStep, rLowerBound, rUpperBound, rStep, epsilon=epsilon,
                                                   winner_number=winnerCount)

        import matplotlib.pyplot as plt

        ax = plt.gca()
        for (x, y, r) in winners:
            circle1 = plt.Circle((x, y), r, color='r', fill=False)
            ax.add_artist(circle1)

        plt.axis('off')
        plt.imshow(img.channels[0], cmap='Greys')
        plt.show()
Exemplo n.º 31
0
 def f(e):
     if e.inaxes is not None:
         ind = self.index_actuator(e.xdata, e.ydata)
         if ind != -1:
             val, ok = QInputDialog.getDouble(
                 parent, f'Actuator {ind}',
                 f'Actuator {ind}; Range [-1, 1]', u[ind], -1., 1., 4)
             if ok:
                 u[ind] = val
                 self.update(u)
                 if write:
                     write(u)
Exemplo n.º 32
0
 def getDouble(self):
     d, okPressed = QInputDialog.getDouble(
         self,
         "Get double",
         "Value:",
         10.05,
         0,
         100,
         10,
     )
     if okPressed:
         print(d)
Exemplo n.º 33
0
 def on_setMinXAction_triggered(self):
     (graphX, ok) = QInputDialog.getDouble(
         self,
         self.tr('Set Min X'),
         self.tr('Set the minimal value of X'),
         self.DEFAULT_VALUE,
         self.MIN_VALUE,
         self.MAX_VALUE,
         self.DIGITS)
     if ok:
         (x, y) = self.pos
         self.setMinX(x, graphX)
Exemplo n.º 34
0
 def askValue(self, ques='Input', isInteger=True):
     inputDlg = QInputDialog()
     if (isInteger):
         i, okPressed = inputDlg.getInt(
             self, 'EnterValue',
             f"<html style='font-size:16pt;'>{ques}</html>", 0, 0, 1000, 1)
     else:
         i, okPressed = inputDlg.getDouble(
             self, 'EnterValue',
             f"<html style='font-size:16pt;'>{ques}</html>", 0.001, 0, 1000,
             5)
     return i
Exemplo n.º 35
0
 def ROI_Spectrum_Saving(self):
     '''Saving the roi pulses and their respective timing to later perform
     an integration to find the MDM'''
     if not self.calibration:
         self.calibration_browse()
     list_time=np.asarray(self.list_time)
     list_channel=np.asarray(self.list_channel)
     calibration=np.asarray(self.calibration_data)
     sync_time=np.asarray(self.sync_time)
     lower,ok=QInputDialog.getDouble(self, 'Lower ROI', 'Lower Bound (MeV)',9.6,0,14,4)
     upper,ok2=QInputDialog.getDouble(self, 'Upper ROI', 'Upper Bound (MeV)',10.9,0,14,4)
     if ok and ok2:
 #     #outputs the pulses and associated times to save and integrate to
 #     #calculate the detection probability at integrated time windows
         s=time.time()
         print('Begin processing data')
         pulses,times=Timing.ROI_Timing(sync_time,int(len(sync_time)),
                                        list_time,list_channel, 
                                        self.delta_time,8192,
                                        calibration,upper,lower)
         print('Done processing in {:.2f}s'.format(time.time()-s))
     return pulses,times
Exemplo n.º 36
0
 def add_custom_line(self):
     wl = QInputDialog.getDouble(self, "Custom Line", "Enter line wavelength in Å", self.fits_spectrum.spectrum.wavelengths[0],self.fits_spectrum.spectrum.wavelengths[0],self.fits_spectrum.spectrum.wavelengths[-1],3)
     if not wl[1]: return
     self.add_lines([{'name': 'Custom Line', 'lambda': wl[0]}])
Exemplo n.º 37
0
def edit_variant(parent):
    selected = parent.ui.variant.currentItem()
    current_row = parent.ui.variant.currentRow()
    new_variant = None

    if selected.variant_type == 2:
        # double
        dialog = QInputDialog.getDouble(parent.dialog,
                                        "Edit Value",
                                        selected.variant_name,
                                        selected.variant_value[0],
                                        decimals=2)
        if dialog[1]:
            # didn't realise i was writing lisp
            new_variant = ItemVariant((selected.variant_name, (selected.variant_type, (dialog[0],))))
    elif selected.variant_type == 3:
        # bool
        if selected.variant_value[0] == 1:
            text = "True"
        else:
            text = "False"

        dialog = QInputDialog.getText(parent.dialog,
                                      "Edit Value (True/False)",
                                      selected.variant_name,
                                      QtWidgets.QLineEdit.Normal,
                                      text)
        if dialog[1]:
            if dialog[0] == "True":
                val = (1,)
            else:
                val = (0,)

            new_variant = ItemVariant((selected.variant_name, (selected.variant_type, val)))
    elif selected.variant_type == 4:
        # int (vlq)
        dialog = QInputDialog.getInt(parent.dialog,
                                     "Edit Value",
                                     selected.variant_name,
                                     selected.variant_value)
        if dialog[1]:
            new_variant = ItemVariant((selected.variant_name, (selected.variant_type, dialog[0])))
    elif selected.variant_type == 5:
        # string
        dialog = QInputDialog.getText(parent.dialog,
                                      "Edit Value",
                                      selected.variant_name,
                                      QtWidgets.QLineEdit.Normal,
                                      selected.variant_value)
        if dialog[1]:
            new_variant = ItemVariant((selected.variant_name, (selected.variant_type, dialog[0])))
    elif selected.variant_type == 6:
        # variant list
        variant_edit = VariantEdit(parent.dialog, selected)
        new_variant = ItemVariant((selected.variant_name,
                                   (selected.variant_type, variant_edit.get_variant())))
    elif selected.variant_type == 7:
        # variant dicts
        variant_edit = VariantEdit(parent.dialog, selected)
        new_variant = ItemVariant((selected.variant_name,
                                   (selected.variant_type, variant_edit.get_variant())))

    if new_variant != None:
        parent.ui.variant.setItem(current_row, 0, new_variant)
 def setDouble(self):    
     d, ok = QInputDialog.getDouble(self, "QInputDialog.getDouble()",
             "Amount:", 3333.00, -10000, 1000000, 1)
     if ok:
         self.doubleLabel.setText("$%g" % d)
         self.effectValue = d
Exemplo n.º 39
0
 def blackbody_dialog(self):
     ok = False
     kelvin = QInputDialog.getDouble(None, "Black Body Radiation", "Enter temperature for black body radiation (°K)", 0, 0)
     if(not kelvin[1]):
         return
     self.on_triggered( BlackBody(kelvin[0]) )
Exemplo n.º 40
0
    def new_item_edit_options(self, new=False, raw=False):
        """Edit the selected item option with custom dialog."""

        if new:
            selected = ItemOptionWidget("", None)
        else:
            selected = self.ui.variant.currentItem()

        dialog = None
        name, value = selected.option

        # TODO: drawable images
        # TODO: status effects
        # TODO: color editing

        if new or raw:
            dialog = ItemEditOptions(self.dialog, name, value)

            def save():
                name, value = dialog.get_option()
                self.item["parameters"][name] = value

            dialog.dialog.accepted.connect(save)
            dialog.dialog.exec()
        elif name in ["inventoryIcon", "image", "largeImage"] and type(value) is str:
            dialog = ImageBrowser(self.dialog, self.assets, False)

            def save():
                value = dialog.get_key()
                self.item["parameters"][name] = value

            dialog.dialog.accepted.connect(save)
            dialog.dialog.exec()
        elif type(value) is str:
            text, ok = QInputDialog.getText(self.dialog, "Edit Text", name, text=value)
            if ok:
                value = text
                self.item["parameters"][name] = value
        elif type(value) is int:
            num, ok = QInputDialog.getInt(self.dialog, "Edit Integer", name, value)
            if ok:
                value = num
                self.item["parameters"][name] = value
        elif type(value) is float:
            num, ok = QInputDialog.getDouble(self.dialog, "Edit Double", name, value, decimals=2)
            if ok:
                value = num
                self.item["parameters"][name] = value
        elif type(value) is bool:
            value = not value
            self.item["parameters"][name] = value
        else:
            dialog = ItemEditOptions(self.dialog, name, value)

            def save():
                name, value = dialog.get_option()
                self.item["parameters"][name] = value

            dialog.dialog.accepted.connect(save)
            dialog.dialog.exec()

        self.update()
Exemplo n.º 41
0
    def edit_variant(self):
        selected = self.ui.variant.currentItem()
        current_row = self.ui.variant.currentRow()
        new_variant = None

        if selected.variant_type == 2:
            # double
            dialog = QInputDialog.getDouble(self.dialog,
                                            "Edit Value",
                                            selected.variant_name,
                                            selected.variant_value[0],
                                            decimals=2)
            if dialog[1]:
                # didn't realise i was writing lisp
                new_variant = ItemVariant((selected.variant_name, (selected.variant_type, (dialog[0],))))
        elif selected.variant_type == 3:
            # bool
            if selected.variant_value[0] == 1:
                text = "True"
            else:
                text = "False"

            dialog = QInputDialog.getText(self.dialog,
                                          "Edit Value (True/False)",
                                          selected.variant_name,
                                          QtWidgets.QLineEdit.Normal,
                                          text)
            if dialog[1]:
                if dialog[0] == "True":
                    val = (1,)
                else:
                    val = (0,)

                new_variant = ItemVariant((selected.variant_name, (selected.variant_type, val)))
        elif selected.variant_type == 4:
            # int (vlq)
            dialog = QInputDialog.getInt(self.dialog,
                                         "Edit Value",
                                         selected.variant_name,
                                         selected.variant_value)
            if dialog[1]:
                new_variant = ItemVariant((selected.variant_name, (selected.variant_type, dialog[0])))
        elif selected.variant_type == 5:
            # string
            dialog = QInputDialog.getText(self.dialog,
                                          "Edit Value",
                                          selected.variant_name,
                                          QtWidgets.QLineEdit.Normal,
                                          selected.variant_value)
            if dialog[1]:
                new_variant = ItemVariant((selected.variant_name, (selected.variant_type, dialog[0])))
        elif selected.variant_type == 6:
            # TODO: both of these will require a fair bit of work
            #       i'd like a recurive variant table
            # variant list
            pass
        elif selected.variant_type == 7:
            # variant dicts
            pass

        if new_variant != None:
            self.ui.variant.setItem(current_row, 0, new_variant)
Exemplo n.º 42
0
 def setDouble(self):    
     d, ok = QInputDialog.getDouble(self, "QInputDialog.getDouble()",
             "Amount:", 37.56, -10000, 10000, 2)
     if ok:
         self.doubleLabel.setText("$%g" % d)
Exemplo n.º 43
0
 def on_get_double_click(self):
     d, ok_pressed = QInputDialog.getDouble(self, 'Get Double', 'Double:', 10.5, 0, 100, 10)
     if ok_pressed:
         print(d)