def __init__(self, symbol, color, parent = None):

        QFrame.__init__(self, parent)
        self._symbol = symbol
        self.backColor = color

        # define and set stylesheets
        self.setup_stylesheets()
        self.setStyleSheet(self._theStyleSheet)

        # layout
        layout    = QHBoxLayout()
        layout.setContentsMargins( 0, 0, 0, 0 )
        self.setToolTip(symbol["description"])

        # add the symbol's svg
        svgWidget = QSvgWidget(symbol["svgPath"]) 
        svgWidth = int(symbol["width"])
        self.setMinimumWidth(svgWidth * 25)
        self.setMaximumWidth(svgWidth * 25)
        self.setMinimumHeight(25)
        self.setMaximumHeight(25)

        layout.addWidget(svgWidget)
        self.setLayout(layout)
示例#2
0
文件: line.py 项目: makerpc/brickv
    def __init__(self, *args):
        PluginBase.__init__(self, BrickletLine, *args)

        self.line = self.device

        self.cbe_reflectivity = CallbackEmulator(self.line.get_reflectivity,
                                                 self.cb_reflectivity,
                                                 self.increase_error_count)

        self.reflectivity_label = ReflectivityLabel()
        self.rf = ReflectivityFrame()

        self.current_value = None

        plot_list = [['', Qt.red, self.get_current_value]]
        self.plot_widget = PlotWidget('Reflectivity', plot_list)

        layout_h = QHBoxLayout()
        layout_h.addStretch()
        layout_h.addWidget(self.reflectivity_label)
        layout_h.addStretch()

        layout_h2 = QHBoxLayout()
        layout_h2.addStretch()
        layout_h2.addWidget(self.rf)
        layout_h2.addStretch()

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h)
        layout.addLayout(layout_h2)
        layout.addWidget(self.plot_widget)
示例#3
0
class MainWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self, None)
        self._setupUi()
        self.model = MainWindowModel()
        self.nameTextBox = LineEdit(view=self.nameTextBoxView)
        self.helloLabel = TextHolder(view=self.helloLabelView)
        self.model.set_children(self.nameTextBox.model, self.helloLabel.model)
        self.randomNameButton.clicked.connect(self.model.select_random_name)
        self.sayHelloButton.clicked.connect(self.model.say_hello)
    
    def _setupUi(self):
        self.setWindowTitle(QCoreApplication.instance().applicationName())
        self.centralwidget = QWidget(self)
        self.verticalLayout = QVBoxLayout(self.centralwidget)
        self.nameTextBoxView = QLineEdit(self.centralwidget)
        self.verticalLayout.addWidget(self.nameTextBoxView)
        self.helloLabelView = QLabel(self.centralwidget)
        self.verticalLayout.addWidget(self.helloLabelView)
        self.buttonLayout = QHBoxLayout()
        self.randomNameButton = QPushButton("Random Name", self.centralwidget)
        self.buttonLayout.addWidget(self.randomNameButton)
        self.sayHelloButton = QPushButton("Say Hello", self.centralwidget)
        self.buttonLayout.addWidget(self.sayHelloButton)
        self.verticalLayout.addLayout(self.buttonLayout)
        self.setCentralWidget(self.centralwidget)
示例#4
0
    def __init__(self):
        QWidget.__init__(self)

        self.__filter_popup = FilterPopup(self)
        self.__filter_popup.filterSettingsChanged.connect(self.onItemChanged)

        layout = QVBoxLayout()

        self.model = DataTypeKeysListModel()
        self.filter_model = DataTypeProxyModel(self.model)

        filter_layout = QHBoxLayout()

        self.search_box = SearchBox()
        self.search_box.filterChanged.connect(self.setSearchString)
        filter_layout.addWidget(self.search_box)

        filter_popup_button = QToolButton()
        filter_popup_button.setIcon(util.resourceIcon("ide/cog_edit.png"))
        filter_popup_button.clicked.connect(self.showFilterPopup)
        filter_layout.addWidget(filter_popup_button)
        layout.addLayout(filter_layout)

        self.data_type_keys_widget = QListView()
        self.data_type_keys_widget.setModel(self.filter_model)
        self.data_type_keys_widget.selectionModel().selectionChanged.connect(self.itemSelected)

        layout.addSpacing(15)
        layout.addWidget(self.data_type_keys_widget, 2)
        layout.addStretch()

        # layout.addWidget(Legend("Default types", DataTypeKeysListModel.DEFAULT_DATA_TYPE))
        layout.addWidget(Legend("Observations available", DataTypeKeysListModel.HAS_OBSERVATIONS))

        self.setLayout(layout)
示例#5
0
    def __init__(self, parent, titre, contenu, fonction_modif):
        QDialog.__init__(self, parent)
        self.setWindowTitle(titre)
        sizer = QVBoxLayout()
        self.parent = parent
        self.fonction_modif = fonction_modif
        self.texte = PythonSTC(self)
#        self.texte.setMinimumSize(300, 10)
        self.texte.setText(contenu)
##        self.texte.SetInsertionPointEnd()
        sizer.addWidget(self.texte)

        boutons = QHBoxLayout()
        self.btn_modif = QPushButton(u"Modifier - F5")
        boutons.addWidget(self.btn_modif)
        self.btn_esc = QPushButton(u"Annuler - ESC")
        boutons.addStretch()
        boutons.addWidget(self.btn_esc)
        sizer.addLayout(boutons)
        self.setLayout(sizer)

        self.btn_modif.clicked.connect(self.executer)
        self.btn_esc.clicked.connect(self.close)

        self.setMinimumSize(400, 500)
        self.texte.setFocus()
示例#6
0
    def __init__(self, ipcon, uid, version):
        PluginBase.__init__(self, ipcon, uid, 'Linear Poti Bricklet', version)
        
        self.lp = BrickletLinearPoti(uid, ipcon)
        
        self.qtcb_position.connect(self.cb_position)
        self.lp.register_callback(self.lp.CALLBACK_POSITION,
                                  self.qtcb_position.emit) 
        
        self.slider = QSlider(Qt.Horizontal)
        self.slider.setRange(0, 100)
        
        self.position_label = PositionLabel('Position: ')
        
        self.current_value = None

        plot_list = [['', Qt.red, self.get_current_value]]
        self.plot_widget = PlotWidget('Position', plot_list)
        
        layout_h = QHBoxLayout()
        layout_h.addStretch()
        layout_h.addWidget(self.position_label)
        layout_h.addWidget(self.slider)
        layout_h.addStretch()

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h)
        layout.addWidget(self.plot_widget)
    def __init__(self, project, parent=None):
        QDialog.__init__(self, parent, Qt.Dialog)
        self.project = project
        self.setWindowTitle(translations.TR_PROJECT_PROPERTIES)
        self.resize(600, 500)
        vbox = QVBoxLayout(self)
        self.tab_widget = QTabWidget()
        self.projectData = ProjectData(self)
        self.projectExecution = ProjectExecution(self)
        self.projectMetadata = ProjectMetadata(self)
        self.tab_widget.addTab(self.projectData, translations.TR_PROJECT_DATA)
        self.tab_widget.addTab(self.projectExecution,
            translations.TR_PROJECT_EXECUTION)
        self.tab_widget.addTab(self.projectMetadata,
            translations.TR_PROJECT_METADATA)

        vbox.addWidget(self.tab_widget)
        self.btnSave = QPushButton(translations.TR_SAVE)
        self.btnCancel = QPushButton(translations.TR_CANCEL)
        hbox = QHBoxLayout()
        hbox.addWidget(self.btnCancel)
        hbox.addWidget(self.btnSave)

        vbox.addLayout(hbox)

        self.connect(self.btnCancel, SIGNAL("clicked()"), self.close)
        self.connect(self.btnSave, SIGNAL("clicked()"), self.save_properties)
    def setModel(self, model):
        """
        Set model used to store the data. This method adds an extra row
        at the end, which is used to keep the "Add..." button.
        """
        super( DatasetDetailedInfoTableView, self ).setModel(model)

        widget = QWidget()
        layout = QHBoxLayout(widget)
        self._addButton = button = AddFileButton(widget, new=True)
        button.addFilesRequested.connect(
                partial(self.addFilesRequested.emit, -1))
        button.addStackRequested.connect(
                partial(self.addStackRequested.emit, -1))
        button.addRemoteVolumeRequested.connect(
                partial(self.addRemoteVolumeRequested.emit, -1))
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(button)
        layout.addStretch()
        widget.setLayout(layout)

        lastRow = self.model().rowCount()-1
        modelIndex = self.model().index( lastRow, 0 )
        self.setIndexWidget( modelIndex, widget )
        # the "Add..." button spans last row
        self.setSpan(lastRow, 0, 1, model.columnCount())
示例#9
0
文件: pdf.py 项目: udgover/pdfview
class PDF(QWidget, Script):
  def __init__(self):
    Script.__init__(self, "pdf")
    self.type = "pdfviewer"
    
  def updateWidget(self):
    pass
  
  def start(self, args):
    self.args = args
    try:
      self.node = args["file"].value()
      f = self.node.open()
      buff = f.read()
      f.close()
      self.document = popplerqt4.Poppler.Document.loadFromData(buff)
    except:
      pass

  def g_display(self):
    QWidget.__init__(self)
    self.hbox = QHBoxLayout()
    self.hbox.setContentsMargins(0, 0, 0, 0)
    pdfPage = self.document.page(1)
    image = pdfPage.renderToImage()
    label = QLabel()
    label.setPixmap(QPixmap.fromImage(image))
    self.hbox.addWidget(label)
    self.setLayout(self.hbox)
示例#10
0
class ProgressDialog(QDialog):
    def __init__(self, parent):
        QDialog.__init__(self, parent)
        self.resize(300, 75)
        self.setWindowTitle("Updating")
        self.vw = QWidget(self)
        self.vl = QVBoxLayout(self.vw)
        self.vl.setMargin(10)
        self.label = QLabel(self.vw)
        self.label.setText("<b>Downloading:</b> library.zip")
        self.vl.addWidget(self.label)
        self.horizontalLayoutWidget = QWidget()
        self.horizontalLayout = QHBoxLayout(self.horizontalLayoutWidget)
        self.horizontalLayout.setMargin(0)
        self.progressbar = QProgressBar(self.horizontalLayoutWidget)
        self.progressbar.setFixedWidth(260)
        self.progressbar.setMinimum(0)
        self.progressbar.setMaximum(100)
        self.stopButton = QPushButton(self.horizontalLayoutWidget)
        self.stopButton.setFlat(True)
        self.stopButton.setIcon(Icons.stop)
        self.stopButton.setFixedSize(16,16)
        self.horizontalLayout.addWidget(self.progressbar)
        self.horizontalLayout.addWidget(self.stopButton)
        self.vl.addWidget(self.horizontalLayoutWidget)
        self.stopButton.clicked.connect(self.forceStop)
        
    def setValue(self,val):
        self.progressbar.setValue(val)
    def forceStop(self):
        self.emit(SIGNAL("forceStop"))
示例#11
0
    def setupUi(self):
        self.setLayout(QVBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)
        self.layout().setSpacing(0)

        self.__mainLayout = QVBoxLayout()
        self.__mainLayout.setContentsMargins(0, 40, 0, 40)
        self.__mainLayout.setSpacing(65)

        self.layout().addLayout(self.__mainLayout)

        self.setStyleSheet(WELCOME_WIDGET_BUTTON_STYLE)

        bottom_bar = QWidget(objectName="bottom-bar")
        bottom_bar_layout = QHBoxLayout()
        bottom_bar_layout.setContentsMargins(20, 10, 20, 10)
        bottom_bar.setLayout(bottom_bar_layout)
        bottom_bar.setSizePolicy(QSizePolicy.MinimumExpanding,
                                 QSizePolicy.Maximum)

        check = QCheckBox(self.tr("Show at startup"), bottom_bar)
        check.setChecked(False)

        self.__showAtStartupCheck = check

        bottom_bar_layout.addWidget(check, alignment=Qt.AlignVCenter | \
                                    Qt.AlignLeft)

        self.layout().addWidget(bottom_bar, alignment=Qt.AlignBottom,
                                stretch=1)

        self.setSizeGripEnabled(False)
        self.setFixedSize(620, 390)
示例#12
0
    def __init__(self, parent=None):
        super(ReplaceWidget, self).__init__(parent)
        hReplace = QHBoxLayout(self)
        hReplace.setContentsMargins(0, 0, 0, 0)
        self._lineReplace = QLineEdit()
        self._lineReplace.setMinimumWidth(250)
        self._btnCloseReplace = QPushButton(
            self.style().standardIcon(QStyle.SP_DialogCloseButton), '')
        self._btnCloseReplace.setIconSize(QSize(16, 16))
        self._btnReplace = QPushButton(self.trUtf8("Replace"))
        self._btnReplaceAll = QPushButton(self.trUtf8("Replace All"))
        self._btnReplaceSelection = QPushButton(
            self.trUtf8("Replace Selection"))
        hReplace.addWidget(self._btnCloseReplace)
        hReplace.addWidget(self._lineReplace)
        hReplace.addWidget(self._btnReplace)
        hReplace.addWidget(self._btnReplaceAll)
        hReplace.addWidget(self._btnReplaceSelection)

        self.connect(self._btnReplace, SIGNAL("clicked()"),
                     self.replace)
        self.connect(self._btnReplaceAll, SIGNAL("clicked()"),
                     self.replace_all)
        self.connect(self._btnReplaceSelection, SIGNAL("clicked()"),
                     self.replace_selected)
    def __init__(self, item, parent=None):
        QDialog.__init__(self, parent, Qt.Dialog)
        self._item = item
        self.setWindowTitle(self.tr("Project Properties"))
        vbox = QVBoxLayout(self)
        self.tab_widget = QTabWidget()
        self.projectData = ProjectData(self)
        self.projectExecution = ProjectExecution(self)
        self.projectMetadata = ProjectMetadata(self)
        self.tab_widget.addTab(self.projectData, self.tr("Project Data"))
        self.tab_widget.addTab(self.projectExecution,
            self.tr("Project Execution"))
        self.tab_widget.addTab(self.projectMetadata,
            self.tr("Project Metadata"))

        vbox.addWidget(self.tab_widget)
        self.btnSave = QPushButton(self.tr("Save"))
        self.btnCancel = QPushButton(self.tr("Cancel"))
        hbox = QHBoxLayout()
        hbox.addWidget(self.btnCancel)
        hbox.addWidget(self.btnSave)

        vbox.addLayout(hbox)

        self.connect(self.btnCancel, SIGNAL("clicked()"), self.close)
        self.connect(self.btnSave, SIGNAL("clicked()"), self.save_properties)
示例#14
0
文件: about.py 项目: debianitram/side
    def __init__(self, parent=None):
        QDialog.__init__(self, parent, Qt.Dialog)
        self.setWindowTitle(self.tr("About SIDE-C"))
        self.setMaximumSize(QSize(0, 0))
        

        vbox = QVBoxLayout(self)

        #Create an icon for the Dialog
        # pixmap = QPixmap(":img/icon")
        # self.lblIcon = QLabel()
        # self.lblIcon.setPixmap(pixmap)

        hbox = QHBoxLayout()
        # hbox.addWidget(self.lblIcon)

        lblTitle = QLabel(
                '<h1>SIDE - C</h1>\n<i>Simple Integrated Development Environment for C<i>')
        lblTitle.setTextFormat(Qt.RichText)
        lblTitle.setAlignment(Qt.AlignLeft)
        hbox.addWidget(lblTitle)
        vbox.addLayout(hbox)
        #Add description
        vbox.addWidget(QLabel(
self.tr("""ALGO ACA""")))
        vbox.addWidget(QLabel("Hola"))
        link_ninja = QLabel(
            self.tr('Website: '))
        vbox.addWidget(link_ninja)
        link_source = QLabel(
            self.tr('Source Code'))
        vbox.addWidget(link_source)
示例#15
0
    def create_main_frame(self):

        self.fig = Figure(dpi=100)
        self.canvas = FigureCanvas(self.fig)
        self.canvas.setParent(self)
        self.canvas.setFocusPolicy( Qt.ClickFocus )
        self.canvas.setFocus()

        self.mpl_toolbar = myNavigationToolbar(self.canvas, self)
        self.canvas.mpl_connect('button_press_event', self.on_click)
        self.canvas.mpl_connect('key_press_event', self.on_key_press)
        self.canvas.mpl_connect('key_release_event', self.on_key_release)
        #self.canvas.mpl_connect('button_press_event', self.disable_clicks)


        self.cbar_button = QPushButton("Color Range")
        self.cbar_button.setFocusPolicy( Qt.NoFocus )
        self.grid_cb = QCheckBox("Show Grid")
        self.grid_cb.setFocusPolicy( Qt.NoFocus )
        self.grid_cb.stateChanged.connect(self.showGrid)

        vbox = QVBoxLayout()
        hbox = QHBoxLayout()

        vbox.addWidget(self.canvas)  # the matplotlib canvas
        hbox.addWidget(self.mpl_toolbar)
        hbox.addWidget(self.cbar_button)
        hbox.addWidget(self.grid_cb)
        vbox.addLayout(hbox)
        self.setLayout(vbox)
示例#16
0
    def __init__(self, *args):
        PluginBase.__init__(self, BrickletUVLight, *args)

        self.uv_light = self.device

        self.cbe_uv_light = CallbackEmulator(self.uv_light.get_uv_light,
                                             self.cb_uv_light,
                                             self.increase_error_count)

        self.uv_label = UVLabel(u'UV Light: ')
        self.index_label = IndexLabel(u'UV Index: ')

        self.current_uv_light = None
        
        plot_list = [['', Qt.red, self.get_current_uv_light]]
        self.plot_widget_uv = PlotWidget(u'UV Light [µW/cm²]', plot_list)
        
        layout_h1 = QHBoxLayout()
        layout_h1.addStretch()
        layout_h1.addWidget(self.uv_label)
        layout_h1.addStretch()
        
        layout_h2 = QHBoxLayout()
        layout_h2.addStretch()
        layout_h2.addWidget(self.index_label)
        layout_h2.addStretch()

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h1)
        layout.addLayout(layout_h2)
        layout.addWidget(self.plot_widget_uv)
示例#17
0
    def __init__(self, suggested, parent=None):
        super(PythonDetectDialog, self).__init__(parent, Qt.Dialog)
        self.setMaximumSize(QSize(0, 0))
        self.setWindowTitle("Configure Python Path")

        vbox = QVBoxLayout(self)

        lblMessage = QLabel(self.tr("We have detected that you are using " +
            "Windows,\nplease choose the proper " +
            "Python application for you:"))
        vbox.addWidget(lblMessage)

        self.listPaths = QListWidget()
        self.listPaths.setSelectionMode(QListWidget.SingleSelection)
        vbox.addWidget(self.listPaths)

        hbox = QHBoxLayout()
        hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding))
        btnCancel = QPushButton(self.tr("Cancel"))
        btnAccept = QPushButton(self.tr("Accept"))
        hbox.addWidget(btnCancel)
        hbox.addWidget(btnAccept)
        vbox.addLayout(hbox)

        self.connect(btnAccept, SIGNAL("clicked()"), self._set_python_path)
        self.connect(btnCancel, SIGNAL("clicked()"), self.close)

        for path in suggested:
            self.listPaths.addItem(path)
        self.listPaths.setCurrentRow(0)
示例#18
0
    def __init__(self, *args):
        PluginBase.__init__(self, BrickletSoundIntensity, *args)

        self.si = self.device

        self.cbe_intensity = CallbackEmulator(self.si.get_intensity,
                                              self.cb_intensity,
                                              self.increase_error_count)

        self.intensity_label = IntensityLabel()
        self.current_value = None
        self.thermo = TuningThermo()

        #plot_list = [['', Qt.red, self.get_current_value]]
        #self.plot_widget = PlotWidget('Intensity Value', plot_list)

        layout_h = QHBoxLayout()
        layout_h.addStretch()
        layout_h.addWidget(self.intensity_label)
        layout_h.addStretch()

        layout_h2 = QHBoxLayout()
        layout_h2.addStretch()
        layout_h2.addWidget(self.thermo)
        layout_h2.addStretch()

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h)
        layout.addLayout(layout_h2)
        layout.addStretch()
示例#19
0
    def __init__(self, pathProjects, parent=None):
        #pathProjects must be a list
        QDialog.__init__(self, parent)
        self.setWindowTitle(self.tr("Add File to Project"))
        self.pathSelected = ''
        vbox = QVBoxLayout(self)

        self._tree = QTreeWidget()
        self._tree.header().setHidden(True)
        self._tree.setSelectionMode(QTreeWidget.SingleSelection)
        self._tree.setAnimated(True)
        vbox.addWidget(self._tree)
        hbox = QHBoxLayout()
        btnAdd = QPushButton(self.tr("Add here!"))
        btnCancel = QPushButton(self.tr("Cancel"))
        hbox.addWidget(btnCancel)
        hbox.addWidget(btnAdd)
        vbox.addLayout(hbox)
        #load folders
        self._root = None
        for pathProject in pathProjects:
            folderStructure = file_manager.open_project(pathProject)
            self._load_project(folderStructure, pathProject)

        self.connect(btnCancel, SIGNAL("clicked()"), self.close)
        self.connect(btnAdd, SIGNAL("clicked()"), self._select_path)
示例#20
0
    def __init__(self, current_case):
        QWidget.__init__(self)

        self.__model = PlotCaseModel()

        self.__signal_mapper = QSignalMapper(self)
        self.__case_selectors = {}
        self.__case_selectors_order = []

        layout = QVBoxLayout()

        add_button_layout = QHBoxLayout()
        button = QPushButton(util.resourceIcon("ide/small/add"), "Add case to plot")
        button.clicked.connect(self.addCaseSelector)

        add_button_layout.addStretch()
        add_button_layout.addWidget(button)
        add_button_layout.addStretch()

        layout.addLayout(add_button_layout)

        self.__case_layout = QVBoxLayout()
        self.__case_layout.setMargin(0)
        layout.addLayout(self.__case_layout)

        self.addCaseSelector(disabled=True, current_case=current_case)
        layout.addStretch()

        self.setLayout(layout)

        self.__signal_mapper.mapped[QWidget].connect(self.removeWidget)
示例#21
0
    def __init__(self, ipcon, uid, version):
        PluginBase.__init__(self, ipcon, uid, 'Line Bricklet', version)

        self.line = BrickletLine(uid, ipcon)
        
        self.qtcb_reflectivity.connect(self.cb_reflectivity)
        self.line.register_callback(self.line.CALLBACK_REFLECTIVITY,
                                    self.qtcb_reflectivity.emit) 
        
        self.reflectivity_label = ReflectivityLabel()
        self.rf = ReflectivityFrame()
        
        self.current_value = None
        
        plot_list = [['', Qt.red, self.get_current_value]]
        self.plot_widget = PlotWidget('Reflectivity', plot_list)
        
        layout_h = QHBoxLayout()
        layout_h.addStretch()
        layout_h.addWidget(self.reflectivity_label)
        layout_h.addStretch()
        
        layout_h2 = QHBoxLayout()
        layout_h2.addStretch()
        layout_h2.addWidget(self.rf)
        layout_h2.addStretch()

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h)
        layout.addLayout(layout_h2)
        layout.addWidget(self.plot_widget)
示例#22
0
    def  __init__(self, image_width, image_height, parent=None):
        super(UserButtonMenu, self).__init__(parent)
        
        self.image_width = image_width
        self.image_height = image_height

        self.label = QLabel(self)
        self.label.setScaledContents(True)
        self.label.setSizePolicy(
                QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored))

        self.imageLabel = QLabel(self)
        self.imageLabel.setScaledContents(True)
        self.imageLabel.setSizePolicy(
                QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum))

        self.setSizePolicy(
                QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum))

        self.userMenu = QMenu('user accounts menu') # TODO Remove magic

        hbox = QHBoxLayout()
        hbox.addWidget(self.imageLabel)
        hbox.addWidget(self.label)
        self.setLayout(hbox)
        self.setMenu(self.userMenu)
示例#23
0
文件: EkdWidgets.py 项目: Ptaah/Ekd
class EkdPathPropertie(EkdPropertie):
    """
    Définition de la propriété correspondant à un chemin
    """
    def __init__(self, prop, name, value, section=None ):
        super(EkdPathPropertie, self).__init__(prop, name, value, EkdPropertie.PATH, section)
        self.label = QLabel(name)
        self.widget = QFrame()
        self.layout = QHBoxLayout(self.widget)
        self.line = QLineEdit(value)
        self.line.setReadOnly(True)
        self.layout.addWidget(self.line)
        self.boutton = QPushButton(u"...")
        self.boutton.setFixedSize(25,25)
        self.layout.addWidget(self.boutton)

        # Quand on clique sur le boutton on défini le path
        self.connect(self.boutton, SIGNAL("clicked()"), self.updatePath)

    def updatePath(self):
        newpath = QFileDialog.getExistingDirectory(None, _(u"Choisissez un chemin"), self.value )
        if newpath:
            self.value = newpath
            self.line.setText(self.value)
            EkdConfig.set(self.section, self.id, self.value)
示例#24
0
class ArgumentWidget(QWidget):
    def __init__(self, argument, parent=None):
        super(ArgumentWidget, self).__init__(parent)
        self.layout = QHBoxLayout()
        self.layout.setContentsMargins(1, 0, 1, 1)
        self.setLayout(self.layout)
        label = QLabel(argument)
        self.component_id = None
        self.layout.addWidget(label)
        self.editor = QLineEdit()
        self.editor.setReadOnly(True)
        self.layout.addWidget(self.editor)
        self.setAcceptDrops(True)

    def dragEnterEvent(self, event):
        if event.mimeData().hasFormat('application/py_instance'):
            event.accept()
        else:
            event.ignore()

    def dropEvent(self, event):
        obj = event.mimeData().data('application/py_instance')
        if not isinstance(obj, core.data.ComponentID):
            return
        self.component_id = obj
        self.editor.setText(str(obj))
示例#25
0
    def __init__(self):
        QWidget.__init__(self)
        self.setContextMenuPolicy(Qt.DefaultContextMenu)
        self.setMinimumHeight(38)
        hbox = QHBoxLayout(self)
        self.btnPrevious = QPushButton(QIcon(resources.IMAGES["nav-code-left"]), "")
        self.btnPrevious.setObjectName("navigation_button")
        self.btnPrevious.setToolTip(self.tr("Right click to change navigation options"))
        self.btnNext = QPushButton(QIcon(resources.IMAGES["nav-code-right"]), "")
        self.btnNext.setObjectName("navigation_button")
        self.btnNext.setToolTip(self.tr("Right click to change navigation options"))
        hbox.addWidget(self.btnPrevious)
        hbox.addWidget(self.btnNext)
        self.setContentsMargins(0, 0, 0, 0)

        self.menuNavigate = QMenu(self.tr("Navigate"))
        self.codeAction = self.menuNavigate.addAction(self.tr("Code Jumps"))
        self.codeAction.setCheckable(True)
        self.codeAction.setChecked(True)
        self.bookmarksAction = self.menuNavigate.addAction(self.tr("Bookmarks"))
        self.bookmarksAction.setCheckable(True)
        self.breakpointsAction = self.menuNavigate.addAction(self.tr("Breakpoints"))
        self.breakpointsAction.setCheckable(True)

        # 0 = Code Jumps
        # 1 = Bookmarks
        # 2 = Breakpoints
        self.operation = 0

        self.connect(self.codeAction, SIGNAL("triggered()"), self._show_code_nav)
        self.connect(self.breakpointsAction, SIGNAL("triggered()"), self._show_breakpoints)
        self.connect(self.bookmarksAction, SIGNAL("triggered()"), self._show_bookmarks)
示例#26
0
    def __init__(self, editorWidget, parent=None):
        QDialog.__init__(self, parent, Qt.Dialog)
        self.setWindowTitle('from ... import ...')
        self._editorWidget = editorWidget

        source = self._editorWidget.get_text()
        source = source.encode(self._editorWidget.encoding)
        self._imports = introspection.obtain_imports(source)

        self._imports_names = list(self._imports["imports"].keys())
        self._imports_names += [imp for imp in self._imports['fromImports']]
        self._froms = [self._imports['fromImports'][imp]['module']
                            for imp in self._imports['fromImports']]
        self._froms += builtin_module_names
        self._froms += [module_name[1] for module_name in iter_modules()]
        self._froms = tuple(sorted(set(self._froms)))

        hbox = QHBoxLayout(self)
        hbox.addWidget(QLabel('from'))
        self._lineFrom = QLineEdit()
        self._completer = QCompleter(self._froms)
        self._lineFrom.setCompleter(self._completer)
        hbox.addWidget(self._lineFrom)
        hbox.addWidget(QLabel('import'))
        self._lineImport = QLineEdit()
        self._completerImport = QCompleter(self._imports_names)
        self._lineImport.setCompleter(self._completerImport)
        hbox.addWidget(self._lineImport)
        self._btnAdd = QPushButton(self.tr('Add'))
        hbox.addWidget(self._btnAdd)

        self.connect(self._lineImport, SIGNAL("returnPressed()"),
            self._add_import)
        self.connect(self._btnAdd, SIGNAL("clicked()"),
            self._add_import)
示例#27
0
    def __init__(self, pathProjects, parent=None):
        #pathProjects must be a list
        QDialog.__init__(self, parent)
        self.setWindowTitle(self.tr("Add File to Project"))
        self.pathSelected = ''
        vbox = QVBoxLayout(self)

        self._tree = QTreeWidget()
        self._tree.header().setHidden(True)
        self._tree.setSelectionMode(QTreeWidget.SingleSelection)
        self._tree.setAnimated(True)
        vbox.addWidget(self._tree)
        hbox = QHBoxLayout()
        btnAdd = QPushButton(self.tr("Add here!"))
        btnCancel = QPushButton(self.tr("Cancel"))
        hbox.addWidget(btnCancel)
        hbox.addWidget(btnAdd)
        vbox.addLayout(hbox)
        #load folders
        self._root = None
        self._loading_items = {}
        self.loading_projects(pathProjects)
        self._thread_execution = ThreadExecution(
            self._thread_load_projects, args=[pathProjects])
        self.connect(self._thread_execution,
                     SIGNAL("finished()"), self._callback_load_project)
        self._thread_execution.start()

        self.connect(btnCancel, SIGNAL("clicked()"), self.close)
        self.connect(btnAdd, SIGNAL("clicked()"), self._select_path)
示例#28
0
文件: EkdWidgets.py 项目: Ptaah/Ekd
class EkdColorPropertie(EkdPropertie):
    """
    Définition de la propriété correspondant à une Couleur
    """
    def __init__(self, prop, name, value, section=None ):
        super(EkdColorPropertie, self).__init__(prop, name, value, EkdPropertie.COLOR, section)
        self.label = QLabel(name)
        self.widget = QFrame()
        self.layout = QHBoxLayout(self.widget)
        self.line = QLineEdit(value)
        self.value = value
        self.line.setReadOnly(True)
        self.layout.addWidget(self.line)
        self.color = QPixmap(15, 15)
        self.color.fill(QColor.fromRgb(int("%d" % int(self.value, 16))))
        self.boutton = QPushButton(QIcon(self.color), u"")
        self.boutton.setFixedSize(25,25)
        self.layout.addWidget(self.boutton)

        # Quand on clique sur le boutton on défini la couleur
        self.connect(self.boutton, SIGNAL("clicked()"), self.updateColor)

    def updateColor(self):
        newcolor = QColorDialog.getColor(QColor.fromRgb(int("%d" % int(self.value, 16))), None )# Non supporté sous Jaunty ??
        if newcolor.isValid():
            self.value = str("%x" % newcolor.rgb())[2:]
            self.color.fill(QColor.fromRgb(int("%d" % int(self.value, 16))))
            self.boutton.setIcon(QIcon(self.color))
            self.line.setText(self.value)
            EkdConfig.set(self.section, self.id, self.value)
示例#29
0
 def create_doublespinbox(self, prefix, suffix, option, 
                    min_=None, max_=None, step=None, tip=None):
     if prefix:
         plabel = QLabel(prefix)
     else:
         plabel = None
     if suffix:
         slabel = QLabel(suffix)
     else:
         slabel = None
     spinbox = QDoubleSpinBox()
     if min_ is not None:
         spinbox.setMinimum(min_)
     if max_ is not None:
         spinbox.setMaximum(max_)
     if step is not None:
         spinbox.setSingleStep(step)
     if tip is not None:
         spinbox.setToolTip(tip)
     self.spinboxes[spinbox] = option
     layout = QHBoxLayout()
     for subwidget in (plabel, spinbox, slabel):
         if subwidget is not None:
             layout.addWidget(subwidget)
     layout.addStretch(1)
     layout.setContentsMargins(0, 0, 0, 0)
     widget = QWidget(self)
     widget.setLayout(layout)
     widget.spin = spinbox
     return widget
示例#30
0
    def __init__(self, possible_items):
        QWidget.__init__(self)

        self._editing = True
        self._possible_items = possible_items

        self._list_edit_line = AutoCompleteLineEdit(possible_items, self)
        self._list_edit_line.setMinimumWidth(350)

        layout = QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)

        layout.addWidget(self._list_edit_line)

        dialog_button = QToolButton(self)
        dialog_button.setIcon(resourceIcon("ide/small/add"))
        dialog_button.setIconSize(QSize(16, 16))
        dialog_button.clicked.connect(self.addChoice)

        layout.addWidget(dialog_button)

        self.setLayout(layout)

        self._validation_support = ValidationSupport(self)
        self._valid_color = self._list_edit_line.palette().color(self._list_edit_line.backgroundRole())

        self._list_edit_line.setText("")
        self._editing = False

        self._list_edit_line.editingFinished.connect(self.validateList)
        self._list_edit_line.textChanged.connect(self.validateList)

        self.validateList()
示例#31
0
    def _getShpFieldsCombobox(self, qgisfield, selected_shpfield=None):
        '''
        Get a combobox filled with the SHP layer fields to insert in a table widget
        
        :param qgisfield: The SHP field
        :type qgisfield: QgsField
        
        :param selected_shpfield: The QGIS field to select
        :type selected_shpfield: QString, str
        
        :returns: A combobox with the QGIS layer fields
        :rtype: QWidget
        '''
        # Datatype mapping allowed while checking. For a given SHP type, several QGIS type may be allowed or compatible
        SHP_QGIS_ALLOWED_DATATYPE_MAP = [(QVariant.String, QVariant.String),
                                         (QVariant.LongLong,
                                          QVariant.LongLong),
                                         (QVariant.LongLong, QVariant.Double),
                                         (QVariant.LongLong, QVariant.String),
                                         (QVariant.Int, QVariant.Int),
                                         (QVariant.Int, QVariant.LongLong),
                                         (QVariant.Int, QVariant.Double),
                                         (QVariant.Int, QVariant.String),
                                         (QVariant.Double, QVariant.Double),
                                         (QVariant.Double, QVariant.String)]

        widget = QWidget()
        combobox = QComboBox()
        layout = QHBoxLayout(widget)
        layout.addWidget(combobox, 1)
        layout.setAlignment(Qt.AlignCenter)
        layout.setContentsMargins(5, 0, 5, 0)
        widget.setLayout(layout)

        shplayer = self.shplayer
        shplayer_fields = shplayer.dataProvider().fields()

        current_item_index = 0
        selected_index = 0

        combobox.addItem(
            QCoreApplication.translate('ImportShpDialog', '<None>'), None)
        current_item_index += 1

        for field in shplayer_fields:
            # Include only fields with compatible data type
            for shp_type, qgis_type in SHP_QGIS_ALLOWED_DATATYPE_MAP:
                if field.type() == shp_type and qgisfield.type() == qgis_type:
                    combobox.addItem(field.name(), field.name())
                    # Select field if same name
                    if field.name() == qgisfield.name(
                    ) and selected_index == 0:
                        selected_index = current_item_index
                    if field.name() == selected_shpfield:
                        selected_index = current_item_index
                    current_item_index += 1
                    break

        combobox.setCurrentIndex(selected_index)
        combobox.currentIndexChanged.connect(
            self._comboboxShpFieldIndexChanged)

        return widget
示例#32
0
    def initView(self):
        self.setWindowFlags(Qt.WindowStaysOnTopHint)

        jsLable = QLabel(u'设置不同运营商扇形的角度和半径长度,\n方便在地图上分辨出各运营商的小区', self)
        jsBox = QHBoxLayout()
        jsBox.addWidget(jsLable)

        patternLabel = QLabel(u'请选择显示模式: ')
        paBox = QHBoxLayout()
        self.pattern1 = QRadioButton(u'指针模式 ', self)
        self.pattern1.setChecked(True)
        self.pattern2 = QRadioButton(u'扇形模式 ', self)
        paBox.addWidget(patternLabel)
        paBox.addStretch(1)
        paBox.addWidget(self.pattern1)
        paBox.addWidget(self.pattern2)

        angle_validator = QIntValidator(0, 360, self)

        ydLable = QLabel(u"角度:", self)
        self.ydInput = QLineEdit(self)
        self.ydInput.setPlaceholderText(u'移动:20')
        self.ydInput.setValidator(angle_validator)
        ydLenLable = QLabel(u'长度:', self)
        self.ydLenInput = QLineEdit(self)
        self.ydLenInput.setPlaceholderText(u'移动:0.0015')
        ydBox = QHBoxLayout()
        ydBox.addWidget(ydLable)
        ydBox.addWidget(self.ydInput)
        ydBox.addWidget(ydLenLable)
        ydBox.addWidget(self.ydLenInput)

        ltLable = QLabel(u'角度:', self)
        self.ltInput = QLineEdit(self)
        self.ltInput.setPlaceholderText(u'联通:30')
        self.ltInput.setValidator(angle_validator)
        ltLenLable = QLabel(u'长度:', self)
        self.ltLenInput = QLineEdit(self)
        self.ltLenInput.setPlaceholderText(u'联通:0.0015')
        ltBox = QHBoxLayout()
        ltBox.addWidget(ltLable)
        ltBox.addWidget(self.ltInput)
        ltBox.addWidget(ltLenLable)
        ltBox.addWidget(self.ltLenInput)

        dxLable = QLabel(u'角度:', self)
        self.dxInput = QLineEdit(self)
        self.dxInput.setPlaceholderText(u'电信:40')
        self.dxInput.setValidator(angle_validator)
        dxLenLable = QLabel(u'长度:', self)
        self.dxLenInput = QLineEdit(self)
        self.dxLenInput.setPlaceholderText(u'电信:0.0015')
        dxBox = QHBoxLayout()
        dxBox.addWidget(dxLable)
        dxBox.addWidget(self.dxInput)
        dxBox.addWidget(dxLenLable)
        dxBox.addWidget(self.dxLenInput)

        ttLable = QLabel(u'角度:', self)
        self.ttInput = QLineEdit(self)
        self.ttInput.setPlaceholderText(u'铁塔:50')
        self.ttInput.setValidator(angle_validator)
        ttLenLable = QLabel(u'长度:', self)
        self.ttLenInput = QLineEdit(self)
        self.ttLenInput.setPlaceholderText(u'铁塔:0.0015')
        ttBox = QHBoxLayout()
        ttBox.addWidget(ttLable)
        ttBox.addWidget(self.ttInput)
        ttBox.addWidget(ttLenLable)
        ttBox.addWidget(self.ttLenInput)

        okBtn = QPushButton(u'确定', self)
        okBtn.clicked.connect(self.okBtnListenner)
        custom_btn = QPushButton(u'切换设置模式', self)
        custom_btn.clicked.connect(self.custom_setting)
        btnBox = QHBoxLayout()
        btnBox.addWidget(okBtn)
        btnBox.addWidget(custom_btn)

        vBox = QVBoxLayout()
        vBox.addLayout(jsBox)
        vBox.addLayout(paBox)
        vBox.addLayout(ydBox)
        vBox.addLayout(ltBox)
        vBox.addLayout(dxBox)
        vBox.addLayout(ttBox)
        vBox.addLayout(btnBox)

        vBox.setStretchFactor(jsLable, 3)
        vBox.setStretchFactor(ydBox, 2)
        vBox.setStretchFactor(ltBox, 2)
        vBox.setStretchFactor(dxBox, 2)
        vBox.setStretchFactor(ttBox, 2)
        vBox.setStretchFactor(btnBox, 1)

        self.setLayout(vBox)
示例#33
0
    def initUI(self):
        self.setWindowFlags(Qt.WindowStaysOnTopHint)

        patternLabel = QLabel(u'请选择显示模式: ')
        paBox = QHBoxLayout()
        self.pattern1 = QRadioButton(u'指针模式 ', self)
        self.pattern1.setChecked(True)
        self.pattern2 = QRadioButton(u'扇形模式 ', self)
        paBox.addWidget(patternLabel)
        paBox.addStretch(1)
        paBox.addWidget(self.pattern1)
        paBox.addWidget(self.pattern2)

        angle_validator = QIntValidator(0, 360, self)
        len_validator = QDoubleValidator(0, 99.99999, 5,
                                         self)  # 取值范围为0~99.99999

        label = QLabel(u"请输入网络制式和频段的相应图形参数:")
        default_label = QLabel(u"默认")
        self.default_angle = QLineEdit()
        self.default_angle.setPlaceholderText(u'角度大小:20')
        self.default_angle.setValidator(angle_validator)
        self.default_len = QLineEdit()
        self.default_len.setPlaceholderText(u'长度:0.0015')
        self.default_len.setValidator(len_validator)
        default_hbox = QHBoxLayout()
        default_hbox.addWidget(default_label)
        default_hbox.setStretchFactor(default_label, 1)
        default_hbox.addWidget(self.default_angle)
        default_hbox.addWidget(self.default_len)
        default_hbox.addStretch(1)

        system = [u"网络制式", u"G", u"D", u"C", u"W", u"T", u"F", u"TDS"]
        frequency = [
            u"频段", u"700M", u"800M", u"900M", u"1800M", u"1900M", u"2100M",
            u"2300M", u"2600M"
        ]

        self.system_combox_1 = QComboBox()
        self.system_combox_1.addItems(system)
        self.frequency_combox_1 = QComboBox()
        self.frequency_combox_1.addItems(frequency)
        self.angle_1 = QLineEdit()
        self.angle_1.setPlaceholderText(u'角度大小:30')
        self.angle_1.setValidator(angle_validator)
        self.len_1 = QLineEdit()
        self.len_1.setPlaceholderText(u'长度:0.0015')
        self.len_1.setValidator(len_validator)
        hbox_1 = QHBoxLayout()
        hbox_1.setSpacing(10)
        hbox_1.addWidget(self.system_combox_1)
        hbox_1.addWidget(self.frequency_combox_1)
        hbox_1.addWidget(self.angle_1)
        hbox_1.addWidget(self.len_1)

        self.system_combox_2 = QComboBox()
        self.system_combox_2.addItems(system)
        self.frequency_combox_2 = QComboBox()
        self.frequency_combox_2.addItems(frequency)
        self.angle_2 = QLineEdit()
        self.angle_2.setPlaceholderText(u'角度大小:40')
        self.angle_2.setValidator(angle_validator)
        self.len_2 = QLineEdit()
        self.len_2.setPlaceholderText(u'长度:0.0015')
        self.len_2.setValidator(len_validator)
        hbox_2 = QHBoxLayout()
        hbox_2.setSpacing(10)
        hbox_2.addWidget(self.system_combox_2)
        hbox_2.addWidget(self.frequency_combox_2)
        hbox_2.addWidget(self.angle_2)
        hbox_2.addWidget(self.len_2)

        self.system_combox_3 = QComboBox()
        self.system_combox_3.addItems(system)
        self.frequency_combox_3 = QComboBox()
        self.frequency_combox_3.addItems(frequency)
        self.angle_3 = QLineEdit()
        self.angle_3.setPlaceholderText(u'角度大小:50')
        self.angle_3.setValidator(angle_validator)
        self.len_3 = QLineEdit()
        self.len_3.setPlaceholderText(u'长度:0.0015')
        self.len_3.setValidator(len_validator)
        hbox_3 = QHBoxLayout()
        hbox_3.setSpacing(10)
        hbox_3.addWidget(self.system_combox_3)
        hbox_3.addWidget(self.frequency_combox_3)
        hbox_3.addWidget(self.angle_3)
        hbox_3.addWidget(self.len_3)

        self.system_combox_4 = QComboBox()
        self.system_combox_4.addItems(system)
        self.frequency_combox_4 = QComboBox()
        self.frequency_combox_4.addItems(frequency)
        self.angle_4 = QLineEdit()
        self.angle_4.setPlaceholderText(u'角度大小:60')
        self.angle_4.setValidator(angle_validator)
        self.len_4 = QLineEdit()
        self.len_4.setPlaceholderText(u'长度:0.0015')
        self.len_4.setValidator(len_validator)
        hbox_4 = QHBoxLayout()
        hbox_4.setSpacing(10)
        hbox_4.addWidget(self.system_combox_4)
        hbox_4.addWidget(self.frequency_combox_4)
        hbox_4.addWidget(self.angle_4)
        hbox_4.addWidget(self.len_4)

        ok = QPushButton(u"确定")
        self.connect(ok, SIGNAL("clicked()"), self.okBtnListenner)
        operator = QPushButton(u'切换设置模式', self)
        operator.clicked.connect(self.operator_setting)
        btn_hbox = QHBoxLayout()
        btn_hbox.setSpacing(15)
        btn_hbox.addWidget(ok)
        btn_hbox.addWidget(operator)

        vbox = QVBoxLayout()
        vbox.setSpacing(10)
        vbox.addWidget(label)
        vbox.addLayout(paBox)
        vbox.addLayout(default_hbox)
        vbox.addLayout(hbox_1)
        vbox.addLayout(hbox_2)
        vbox.addLayout(hbox_3)
        vbox.addLayout(hbox_4)
        vbox.addStretch(1)
        vbox.addLayout(btn_hbox)

        self.setLayout(vbox)
示例#34
0
    def __init__(self, session, parent=None):
        super(ExpensesDialog, self).__init__(parent)
        self.session = session
        session = self.pullOnes('session', session)
        self.sessionname = str(session['name']) + ' Session'
        self.pagetitle = self.sessionname
        self.tableFont = QFont('Century Gothic', 8)
        #self.tableFont.setFamily('Century Gothic')
        self.tableHeaderStyle = "::section {" "background-color: teal; color:white}"
        #pull all CA
        self.editID = 0
        self.hold_account = {}
        self.hold_expenses = {}
        self.hold_expensesGroup = {}

        from_label = QLabel('From:')
        to_label = QLabel('To:')
        self.fromData = QDateEdit()
        self.toData = QDateEdit()
        currentDate = QDate()
        self.fromData.setDate(currentDate.currentDate())
        self.fromData.setCalendarPopup(True)
        self.toData.setDate(currentDate.currentDate())
        self.toData.setCalendarPopup(True)
        self.pull_btn = QPushButton()
        self.pull_btn.setText("Load")
        h_pull_box = QHBoxLayout()
        h_pull_box.addWidget(from_label)
        h_pull_box.addWidget(self.fromData)
        h_pull_box.addWidget(to_label)
        h_pull_box.addWidget(self.toData)
        h_pull_box.addWidget(self.pull_btn)

        expensesGroup = self.pullGroupExpenses()
        account = self.pullAccount()

        self.expenseGroupText = QLabel('Category')
        self.expenseGroupData = QComboBox()
        self.expenseGroupData.currentIndexChanged.connect(self.reloadExpenses)
        self.expenseText = QLabel('Expenses')
        self.expenseData = QComboBox()
        self.amountText = QLabel('Amount')
        self.amountData = QLineEdit()
        self.amountData.setPlaceholderText('0000.00')
        self.tellerText = QLabel('Teller/Reciept No.')
        self.tellerData = QLineEdit()
        self.tellerData.setPlaceholderText('xxxxxxxxx')
        self.accountText = QLabel('Account')
        self.accountData = QComboBox()
        self.dateText = QLabel('Date')
        self.dateData = QDateEdit()
        self.dateData.setDate(currentDate.currentDate())
        self.dateData.setCalendarPopup(True)
        self.descriptionText = QLabel('Brief Description')
        self.descriptionData = QPlainTextEdit()
        self.descriptionData.move(200, 100)
        hboz = QHBoxLayout()
        self.gender = QLabel('State')
        self.r1 = QRadioButton('Expenses')
        self.r1.setChecked(True)
        self.r2 = QRadioButton('Refund')
        hboz.addWidget(self.r1)
        hboz.addWidget(self.r2)

        i = 0
        for a in expensesGroup:
            self.hold_expensesGroup[i] = a['id']
            tex = str(a['name']).upper()
            self.expenseGroupData.addItem(tex)
            i += 1

        i = 0
        exp_key = self.hold_expensesGroup[self.expenseGroupData.currentIndex()]
        expenses = self.pullExpenses(exp_key)
        for a in expenses:
            self.hold_expenses[i] = a['id']
            tex = str(a['name']).upper()
            self.expenseData.addItem(tex)
            i += 1

        i = 0
        for a in account:
            self.hold_account[i] = a['id']
            tex = str(a['name']).upper()
            self.accountData.addItem(tex)
            i += 1

        self.FormLayout = QFormLayout()
        self.FormLayout.addRow(self.expenseGroupText, self.expenseGroupData)
        self.FormLayout.addRow(self.expenseText, self.expenseData)
        self.FormLayout.addRow(self.accountText, self.accountData)
        self.FormLayout.addRow(self.tellerText, self.tellerData)
        self.FormLayout.addRow(self.amountText, self.amountData)
        self.FormLayout.addRow(self.gender, hboz)
        self.FormLayout.addRow(self.dateText, self.dateData)
        self.FormLayout.addRow(self.descriptionText, self.descriptionData)

        groupBox1 = QGroupBox('Add Expenses')
        groupBox1.setLayout(self.FormLayout)

        self.pb = QPushButton()
        self.pb.setObjectName("Add")
        self.pb.setText("Add Expenses")

        self.pb1 = QPushButton()
        self.pb1.setObjectName("Edit")
        self.pb1.setText("Edit Row")
        self.pb1.setEnabled(False)

        self.pb2 = QPushButton()
        self.pb2.setObjectName("Close")
        self.pb2.setText("Close")

        self.pb3 = QPushButton()
        self.pb3.setObjectName("Delete")
        self.pb3.setText("Delete Row")
        self.pb3.setEnabled(False)

        self.pb4 = QPushButton()
        self.pb4.setObjectName("Reset")
        self.pb4.setText("Reset")
        self.pb4.hide()

        self.pb5 = QPushButton()
        self.pb5.setObjectName("Change")
        self.pb5.setText("Change Expenses")
        self.pb5.hide()

        self.pb6 = QPushButton()
        self.pb6.setObjectName("Clear")
        self.pb6.setText("Clear Selection")
        self.pb6.setEnabled(False)

        hbo = QHBoxLayout()
        hbo.addWidget(self.pb)
        hbo.addWidget(self.pb5)
        hbo.addWidget(self.pb4)
        hbo.addWidget(self.pb2)
        groupBox2 = QGroupBox('Expenses Data')
        groupBox2.setLayout(hbo)

        self.cols = ['SN', 'EXPENSES', 'ACCOUNT', 'AMOUNT', 'DATE']
        al = self.pullExpensesData()
        if len(al) > 0:
            al = al
        else:
            al = {}

        self.table = QTableWidget()
        header = self.table.horizontalHeader()
        header.setResizeMode(QHeaderView.ResizeToContents)
        header.setStretchLastSection(True)
        header.setStyleSheet(self.tableHeaderStyle)
        vheader = self.table.verticalHeader()
        vheader.setStyleSheet(self.tableHeaderStyle)
        # Body
        self.table.setWindowTitle("Expenses")
        self.table.resize(300, 250)
        self.table.setFont(self.tableFont)
        self.table.setSortingEnabled(2)
        #self.table.resizeColumnsToContents()
        self.table.setRowCount(len(al))
        self.table.setColumnCount(len(self.cols))
        self.table.setHorizontalHeaderLabels(self.cols)
        self.table.setContextMenuPolicy(Qt.CustomContextMenu)
        self.table.customContextMenuRequested.connect(self.handleHeaderMenu)
        self.table.hideColumn(0)
        self.table.setSelectionMode(QAbstractItemView.MultiSelection)
        self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.table.setEditTriggers(QAbstractItemView.NoEditTriggers)

        i = 0
        for q in al:
            #row id
            self.table.setItem(i, 0, QTableWidgetItem(str(q['id'])))
            self.table.setItem(i, 1,
                               QTableWidgetItem(str(q['expensename']).upper()))
            self.table.setItem(i, 2,
                               QTableWidgetItem(str(q['accountname']).upper()))
            zamt = str("{:,}".format(float(q['amount'])))
            self.table.setItem(i, 3, QTableWidgetItem(zamt))
            damz = float(q['datepaid'])
            damt = datetime.utcfromtimestamp(damz).strftime('%d-%m-%Y')
            self.table.setItem(i, 4, QTableWidgetItem(str(damt)))
            i += 1
        self.table.itemSelectionChanged.connect(self.confirmSelection)
        self.table.resizeRowsToContents()
        v_pull_box = QVBoxLayout()
        self.h1_pull_box = QVBoxLayout()
        self.h1_pull_box.addWidget(self.table)
        v_pull_box.addLayout(h_pull_box)
        v_pull_box.addLayout(self.h1_pull_box)
        h2_pull_box = QHBoxLayout()
        h2_pull_box.addWidget(self.pb1)
        h2_pull_box.addWidget(self.pb3)
        h2_pull_box.addWidget(self.pb6)
        v_pull_box.addLayout(h2_pull_box)

        groupBox3 = QGroupBox()
        groupBox3.setLayout(hbo)
        groupBox2.setLayout(v_pull_box)

        grid = QGridLayout()
        grid.addWidget(groupBox1, 0, 0)
        grid.addWidget(groupBox2, 0, 1, 2, 1)
        grid.addWidget(groupBox3, 1, 0)

        self.setLayout(grid)
        self.connect(self.pb, SIGNAL("clicked()"), lambda: self.button_click())
        self.connect(self.pb1, SIGNAL("clicked()"),
                     lambda: self.button_editshow())
        self.connect(self.pb2, SIGNAL("clicked()"),
                     lambda: self.button_close(self))
        self.connect(self.pb3, SIGNAL("clicked()"),
                     lambda: self.button_delete())
        self.connect(self.pb4, SIGNAL("clicked()"),
                     lambda: self.button_reset())
        self.connect(self.pb5, SIGNAL("clicked()"), lambda: self.button_edit())
        self.connect(self.pb6, SIGNAL("clicked()"),
                     lambda: self.button_clear())
        self.connect(self.pull_btn,
                     SIGNAL("clicked()"),
                     lambda x=1: self.reloadTable(x))

        self.setWindowTitle(self.pagetitle)
示例#35
0
class GeobricksTRMM:
    def __init__(self, iface):
        self.iface = iface
        self.plugin_dir = os.path.dirname(__file__)
        locale = QSettings().value('locale/userLocale')[0:2]
        locale_path = os.path.join(self.plugin_dir, 'i18n',
                                   'geobricks_trmm_qgis_{}.qm'.format(locale))
        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)
        self.layout = QVBoxLayout()
        self.username = QLineEdit()
        self.username.setPlaceholderText(
            self.tr('e.g. [email protected]'))
        self.password = QLineEdit()
        self.password.setEchoMode(QLineEdit.Password)
        self.password.setPlaceholderText(
            self.tr('e.g. [email protected]'))
        self.download_folder = QLineEdit()
        try:
            if self.last_download_folder is not None:
                self.download_folder.setText(self.last_download_folder)
        except:
            self.last_download_folder = None
        self.frequency = QComboBox()
        self.frequency.addItem(self.tr('Daily Sum'), 'SUM')
        self.frequency.addItem(self.tr('Daily Average'), 'AVG')
        self.frequency.addItem(self.tr('None'), 'NONE')
        self.from_date = QCalendarWidget()
        self.to_date = QCalendarWidget()
        self.bar = QgsMessageBar()
        self.lbl_0 = QLabel('<b>' + self.tr('Username') + '</b>')
        self.lbl_1 = QLabel('<b>' + self.tr('Password') + '</b>')
        self.lbl_2 = QLabel('<b>' + self.tr('Aggregation') + '</b>')
        self.from_date_label = QLabel(
            '<b>' + self.tr('From Date') + '</b>: ' +
            QDate(2015, 7, 31).toString('MMMM d, yyyy'))
        self.to_date_label = QLabel(
            '<b>' + self.tr('To Date') + '</b>: ' +
            QDate(2015, 7, 31).toString('MMMM d, yyyy'))
        self.lbl_5 = QLabel('<b>' + self.tr('Download Folder') + '</b>')
        self.lbl_6 = QLabel('<i style="color: blue;">' +
                            self.tr('Create an account') + '</i>')
        self.lbl_7 = QLabel('<b>' + self.tr('Data availability') + '</b>: ' +
                            self.tr('from January 1st 1998 to July 31st 2015'))
        self.palette = QPalette()
        self.from_date_widget = QWidget()
        self.from_date_widget_layout = QVBoxLayout()
        self.dates_widget = QWidget()
        self.dates_widget_layout = QHBoxLayout()
        self.username_widget = QWidget()
        self.username_layout = QVBoxLayout()
        self.password_widget = QWidget()
        self.password_layout = QVBoxLayout()
        self.progressBar = QProgressBar()
        self.progress_label = QLabel('<b>' + self.tr('Progress') + '</b>')
        self.login_widget = QWidget()
        self.login_layout = QHBoxLayout()
        self.download_folder_widget = QWidget()
        self.download_folder_layout = QHBoxLayout()
        self.download_folder_button = QPushButton(self.tr('...'))
        self.download_button = QPushButton(self.tr('Start Download'))
        self.close_button = QPushButton(self.tr('Close Window'))
        self.add_to_canvas = QCheckBox(self.tr('Add output layer to canvas'))
        self.add_to_canvas.setChecked(True)
        self.to_date_widget = QWidget()
        self.to_date_widget_layout = QVBoxLayout()
        self.spacing = 16

        self.dlg = GeobricksTRMMDialog()
        self.actions = []
        self.menu = self.tr('Download Data')
        self.toolbar = self.iface.addToolBar(self.tr('TRMM Data Downloader'))
        self.toolbar.setObjectName('TRMMDataDownloader')
        self.is_rendered = False

    def run(self):

        # Build UI
        self.build_ui()

    def build_ui(self):

        # Link label
        self.lbl_6.mousePressEvent = open_browser_registration
        self.palette.setColor(QPalette.Foreground, QColor('blue'))
        self.lbl_6.setPalette(self.palette)

        # Calendars
        self.from_date.setMinimumDate(QDate(1998, 1, 1))
        self.from_date.setMaximumDate(QDate(2015, 7, 31))
        self.to_date.setMinimumDate(QDate(1998, 1, 1))
        self.to_date.setMaximumDate(QDate(2015, 7, 31))

        # Message bar
        self.bar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
        self.layout.addWidget(self.bar)

        # From date panel
        self.from_date_widget_layout.setContentsMargins(0, 0, 0, 0)
        self.from_date_widget_layout.setSpacing(self.spacing)
        self.from_date_widget.setLayout(self.from_date_widget_layout)
        self.from_date_widget_layout.addWidget(self.from_date_label)
        self.from_date_widget_layout.addWidget(self.from_date)
        self.from_date.clicked[QDate].connect(self.update_from_label)

        # To date panel
        self.to_date_widget_layout.setContentsMargins(0, 0, 0, 0)
        self.to_date_widget_layout.setSpacing(self.spacing)
        self.to_date_widget.setLayout(self.to_date_widget_layout)
        self.to_date_widget_layout.addWidget(self.to_date_label)
        self.to_date_widget_layout.addWidget(self.to_date)
        self.to_date.clicked[QDate].connect(self.update_to_label)

        # Dates panel
        self.dates_widget_layout.setContentsMargins(0, 0, 0, 0)
        self.dates_widget_layout.setSpacing(self.spacing)
        self.dates_widget.setLayout(self.dates_widget_layout)
        self.dates_widget_layout.addWidget(self.from_date_widget)
        self.dates_widget_layout.addWidget(self.to_date_widget)

        # Username panel
        self.username_layout.setContentsMargins(0, 0, 0, 0)
        self.username_layout.setSpacing(self.spacing)
        self.username_widget.setLayout(self.username_layout)
        self.username_layout.addWidget(self.lbl_0)
        self.username_layout.addWidget(self.username)

        # Password panel
        self.password_layout.setContentsMargins(0, 0, 0, 0)
        self.password_layout.setSpacing(self.spacing)
        self.password_widget.setLayout(self.password_layout)
        self.password_layout.addWidget(self.lbl_1)
        self.password_layout.addWidget(self.password)

        # Login panel
        self.login_layout.setContentsMargins(0, 0, 0, 0)
        self.login_layout.setSpacing(self.spacing)
        self.login_widget.setLayout(self.login_layout)
        self.login_layout.addWidget(self.username_widget)
        self.login_layout.addWidget(self.password_widget)

        # Download folder panel
        self.download_folder_layout.setContentsMargins(0, 0, 0, 0)
        self.download_folder_layout.setSpacing(0)
        self.download_folder_widget.setLayout(self.download_folder_layout)
        self.download_folder_button.clicked.connect(self.select_output_file)
        self.download_folder_layout.addWidget(self.download_folder)
        self.download_folder_layout.addWidget(self.download_folder_button)

        # Download button
        self.download_button.clicked.connect(self.start)

        # Close button
        self.close_button.clicked.connect(self.close)

        # Add widgets to layout
        self.layout.addWidget(self.login_widget)
        self.layout.addWidget(self.lbl_6)
        self.layout.addWidget(self.lbl_2)
        self.layout.addWidget(self.frequency)
        self.layout.addWidget(self.dates_widget)
        self.layout.addWidget(self.lbl_5)
        self.layout.addWidget(self.download_folder_widget)
        self.layout.addWidget(self.add_to_canvas)
        self.layout.addWidget(self.download_button)
        self.layout.addWidget(self.progress_label)
        self.layout.addWidget(self.progressBar)
        self.layout.addWidget(self.close_button)

        # Set layout
        self.dlg.setLayout(self.layout)

        # Show dialog
        self.dlg.show()

    def update_from_label(self, date):
        self.from_date_label.setText('<b>' + self.tr('From Date') + '</b>: ' +
                                     date.toString('MMMM d, yyyy'))

    def update_to_label(self, date):
        self.to_date_label.setText('<b>' + self.tr('To Date') + '</b>: ' +
                                   date.toString('MMMM d, yyyy'))

    def select_output_file(self):
        filename = QFileDialog.getExistingDirectory(self.dlg,
                                                    self.tr('Select Folder'))
        self.last_download_folder = filename
        self.download_folder.setText(self.last_download_folder)

    def tr(self, message):
        return QCoreApplication.translate('geobricks_trmm_qgis', message)

    def add_action(self,
                   icon_path,
                   text,
                   callback,
                   enabled_flag=True,
                   add_to_menu=True,
                   add_to_toolbar=True,
                   status_tip=None,
                   whats_this=None,
                   parent=None):
        icon = QIcon(icon_path)
        action = QAction(icon, text, parent)
        action.triggered.connect(callback)
        action.setEnabled(enabled_flag)
        if status_tip is not None:
            action.setStatusTip(status_tip)
        if whats_this is not None:
            action.setWhatsThis(whats_this)
        if add_to_toolbar:
            self.toolbar.addAction(action)
        if add_to_menu:
            self.iface.addPluginToMenu(self.menu, action)
        self.actions.append(action)
        return action

    def initGui(self):
        icon_path = ':/plugins/geobricks_qgis_plugin_trmm/icon.png'
        self.add_action(icon_path,
                        text=self.tr('TRMM Data Downloader'),
                        callback=self.run,
                        parent=self.iface.mainWindow())

    def unload(self):
        for action in self.actions:
            self.iface.removePluginMenu('TRMMDataDownloader', action)
            self.iface.removeToolBarIcon(action)
        del self.toolbar

    def close(self):
        self.dlg.close()

    def start(self):
        p = self.collect_parameters()
        if p is not None:
            self.progressBar.setMaximum(100)
            self.progressBar.setValue(0)
            i = 0
            try:
                range = date_range(p['from_date'], p['to_date'])
                for current_date in range:
                    layers = list_layers(p['username'], p['password'],
                                         current_date.year, current_date.month,
                                         current_date.day, p['download_path'])
                    if p['frequency'] is not 'NONE':
                        self.aggregate_layers(layers, current_date)
                    else:
                        if p['open_in_qgis'] is True:
                            for l in layers:
                                if '.tfw' not in l:
                                    self.iface.addRasterLayer(l, str(l))
                    i += 1
                    percent = (i / float(len(range))) * 100
                    self.progressBar.setValue(percent)
            except Exception, e:
                self.bar.pushMessage(None,
                                     str(e),
                                     level=QgsMessageBar.CRITICAL)
    def createWidgets(self):
        """
        """
        self.listingTab = QTabWidget()
        self.listingTab.setMinimumWidth(650)

        layoutGrid = QGridLayout()

        self.testSetPath = QLineEdit()
        self.testSetName = QLineEdit()

        self.testsTable = TestsTableView(self, core=self.core())
        self.testcasesTable = TestcasesTableView(self, core=self.core())

        self.stepsTable = StepsTableView(self, core=self.core())

        self.listingTab.addTab(self.testsTable, "Test(s)")
        self.listingTab.addTab(self.testcasesTable, "Testcase(s)")
        self.listingTab.addTab(self.stepsTable, "Steps(s)")

        self.ignoreTestcases = QCheckBox("Ignore testcase(s)")
        if self.core().settings().cfg()["export-results"]["ignore-testcase"]:
            self.ignoreTestcases.setCheckState(Qt.Checked)

        self.ignoreUncomplete = QCheckBox("Ignore uncomplete result(s)")
        if self.core().settings().cfg()["export-results"]["ignore-uncomplete"]:
            self.ignoreUncomplete.setCheckState(Qt.Checked)

        self.addMissingFoldersCheckBox = QCheckBox(
            self.tr("Create missing folders"))
        if self.core().settings().cfg()["export-results"]["add-folders"]:
            self.addMissingFoldersCheckBox.setCheckState(Qt.Checked)

        self.addTestsetCheckBox = QCheckBox(self.tr("Create testset"))
        if self.core().settings().cfg()["export-results"]["add-testset"]:
            self.addTestsetCheckBox.setCheckState(Qt.Checked)

        self.addTestinstanceCheckBox = QCheckBox(
            self.tr("Add test instance in testset"))
        if self.core().settings().cfg()["export-results"]["add-testinstance"]:
            self.addTestinstanceCheckBox.setCheckState(Qt.Checked)

        optionsLayout = QHBoxLayout()
        optionsLayout.addWidget(self.ignoreTestcases)
        optionsLayout.addWidget(self.ignoreUncomplete)
        optionsLayout.addStretch(1)

        # optionsTsLayout = QHBoxLayout()
        # optionsTsLayout.addWidget(self.addTestsetCheckBox)
        # optionsTsLayout.addWidget(self.addTestinstanceCheckBox)
        # optionsTsLayout.addStretch(1)

        layoutGrid.addWidget(QLabel("Remote Test Set Path:"), 0, 0)
        layoutGrid.addWidget(self.testSetPath, 0, 1)
        # layoutGrid.addWidget(self.addMissingFoldersCheckBox, 1, 1)
        layoutGrid.addWidget(QLabel("Remote Test Set Name:"), 2, 0)
        layoutGrid.addWidget(self.testSetName, 2, 1)
        # layoutGrid.addLayout(optionsTsLayout, 3, 1)
        layoutGrid.addWidget(QLabel("Local result(s):"), 4, 0)
        layoutGrid.addLayout(optionsLayout, 4, 1)
        layoutGrid.addWidget(QLabel("Test(s) Verdict:"), 5, 0)
        layoutGrid.addWidget(self.listingTab, 5, 1)

        self.exportStatusLabel = QLabel("Status: Disconnected", self)
        self.exportButton = QPushButton(self.tr("Export Result"), self)
        self.exportButton.setMinimumWidth(300)

        layoutRight = QHBoxLayout()
        layoutRight.addWidget(self.exportButton)
        layoutRight.addWidget(self.exportStatusLabel)
        layoutRight.addStretch(1)

        layoutGrid.addWidget(QLabel("Controls:"), 6, 0)
        layoutGrid.addLayout(layoutRight, 6, 1)

        layoutMain = QHBoxLayout()
        layoutMain.addLayout(layoutGrid)

        self.setLayout(layoutMain)
示例#37
0
    def __init__(self, parent=None):
        super(LogDialog, self).__init__(parent)

        self.resize(800, 500)

        self.app = QApplication.instance()

        icon = QIcon()
        icon.addPixmap(QPixmap(_fromUtf8(":/freeseer/logo.png")), QIcon.Normal,
                       QIcon.Off)
        self.setWindowIcon(icon)

        layout = QVBoxLayout()
        self.setLayout(layout)

        self.level = 0
        self.handler = LogHandler()

        self.table_model = QStandardItemModel(0, 5)
        header_names = ["Date", "Level", "Module", "Message", "LevelNo"]
        date_column = header_names.index("Date")
        level_column = header_names.index("Level")
        module_column = header_names.index("Module")
        self.level_num_column = header_names.index("LevelNo")
        self.table_model.setHorizontalHeaderLabels(header_names)

        self.table_view = QTableView()
        self.table_view.setModel(self.table_model)
        self.table_view.horizontalHeader().setStretchLastSection(True)
        self.table_view.setColumnWidth(date_column,
                                       self.set_width_with_dpi(125))
        self.table_view.setColumnWidth(level_column,
                                       self.set_width_with_dpi(60))
        self.table_view.setColumnWidth(module_column,
                                       self.set_width_with_dpi(250))
        self.table_view.setColumnHidden(self.level_num_column, True)
        self.table_view.setShowGrid(False)
        self.table_view.horizontalHeader().setClickable(False)
        self.table_view.verticalHeader().hide()
        self.table_view.setStyleSheet("""Qtable_view::item {
            border-bottom: 1px solid lightgrey;
            selection-background-color: white;
            selection-color: black;
            }""")

        top_panel = QHBoxLayout()
        self.log_levels = ["Debug", "Info", "Warning", "Error"]
        self.level_colors = ["#3E4C85", "#269629", "#B0AB21", "#B32020"]

        self.levels_label = QLabel("Filter Level: ")
        self.levels_label.setStyleSheet("QLabel { font-weight: bold }")
        self.current_level_label = QLabel(self.log_levels[0])
        self.current_level_label.setStyleSheet("QLabel {{ color: {} }}".format(
            self.level_colors[0]))
        self.clear_button = QPushButton("Clear Log")
        self.levels_slider = QSlider(Qt.Horizontal)
        self.levels_slider.setStyleSheet("""
        QSlider::handle:horizontal {
            background: qlineargradient(x1:0, y1:0, x2:1, y2:1,
                stop:0 #FFFFFF, stop:1 #E3E3E3);
            border: 1px solid #707070;
            width: 10px;
            margin-top: -4px;
            margin-bottom: -4px;
            border-radius: 4px;
        }

        QSlider::handle:horizontal:hover {
            background: qlineargradient(x1:0, y1:0, x2:1, y2:1,
                stop:0 #DEDEDE, stop:1 #C9C9C9);
            border: 1px solid #4F4F4F;
            border-radius: 4px;
        }

        QSlider::sub-page:horizontal {
            background: qlineargradient(x1: 0, y1: 0,    x2: 0, y2: 1,
                stop: 0 #BFBFBF, stop: 1 #9E9E9E);
            background: qlineargradient(x1: 0, y1: 0.2, x2: 1, y2: 1,
                stop: 0 #9E9E9E, stop: 1 #858585);
            border: 1px solid #777;
            height: 10px;
            border-radius: 4px;
        }

        QSlider::add-page:horizontal {
            background: #fff;
            border: 1px solid #707070;
            height: 10px;
            border-radius: 4px;
        }""")
        self.levels_slider.setRange(0, len(self.log_levels) - 1)
        self.levels_slider.setTickPosition(QSlider.TicksBelow)
        self.levels_slider.setTickInterval(1)

        top_panel.addSpacerItem(self.qspacer_item_with_dpi(10, 0))
        top_panel.addWidget(self.levels_label, 3)
        top_panel.addWidget(self.current_level_label, 2)
        top_panel.addWidget(self.levels_slider, 8)
        top_panel.addSpacerItem(self.qspacer_item_with_dpi(25, 0))
        top_panel.addWidget(self.clear_button, 10)

        layout.addLayout(top_panel)
        layout.addWidget(self.table_view)

        self.connect(self.clear_button, SIGNAL('clicked()'),
                     functools.partial(self.table_model.setRowCount, 0))
        self.connect(self.levels_slider, SIGNAL('valueChanged(int)'),
                     self.slider_set_level)

        self.setWindowTitle("Log")
        self.handler.add_listener(self)
class QgsTextAnnotationDialog(QDialog):
    def __init__(self, item):
        QDialog.__init__(self)
        self.gridLayout = QGridLayout(self)
        self.gridLayout.setObjectName(("gridLayout"))
        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setObjectName(("horizontalLayout"))
        self.mFontComboBox = QFontComboBox(self)
        self.mFontComboBox.setObjectName(("mFontComboBox"))
        self.horizontalLayout.addWidget(self.mFontComboBox)
        spacerItem = QSpacerItem(38, 20, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.mFontSizeSpinBox = QSpinBox(self)
        self.mFontSizeSpinBox.setObjectName(("mFontSizeSpinBox"))
        self.horizontalLayout.addWidget(self.mFontSizeSpinBox)
        self.mBoldPushButton = QPushButton(self)
        self.mBoldPushButton.setMinimumSize(QSize(50, 0))
        self.mBoldPushButton.setCheckable(True)
        self.mBoldPushButton.setObjectName(("mBoldPushButton"))
        self.horizontalLayout.addWidget(self.mBoldPushButton)
        self.mItalicsPushButton = QPushButton(self)
        self.mItalicsPushButton.setMinimumSize(QSize(50, 0))
        self.mItalicsPushButton.setCheckable(True)
        self.mItalicsPushButton.setObjectName(("mItalicsPushButton"))
        self.horizontalLayout.addWidget(self.mItalicsPushButton)
        self.mFontColorButton = QgsColorButton(self)
        self.mFontColorButton.setText((""))
        self.mFontColorButton.setAutoDefault(False)
        self.mFontColorButton.setObjectName(("mFontColorButton"))
        self.horizontalLayout.addWidget(self.mFontColorButton)
        self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1)
        self.mButtonBox = QDialogButtonBox(self)
        self.mButtonBox.setOrientation(Qt.Horizontal)
        self.mButtonBox.setStandardButtons(QDialogButtonBox.Cancel
                                           | QDialogButtonBox.Ok)
        self.mButtonBox.setObjectName(("mButtonBox"))
        self.gridLayout.addWidget(self.mButtonBox, 3, 0, 1, 1)
        self.mTextEdit = QTextEdit(self)
        self.mTextEdit.setObjectName(("mTextEdit"))
        self.gridLayout.addWidget(self.mTextEdit, 1, 0, 1, 1)
        self.mStackedWidget = QStackedWidget(self)
        self.mStackedWidget.setObjectName(("mStackedWidget"))
        self.page = QWidget()
        self.page.setObjectName(("page"))
        self.mStackedWidget.addWidget(self.page)
        self.page_2 = QWidget()
        self.page_2.setObjectName(("page_2"))
        self.mStackedWidget.addWidget(self.page_2)
        self.gridLayout.addWidget(self.mStackedWidget, 2, 0, 1, 1)
        self.setLayout(self.gridLayout)

        self.mStackedWidget.setCurrentIndex(0)
        QObject.connect(self.mButtonBox, SIGNAL(("accepted()")), self.accept)
        QObject.connect(self.mButtonBox, SIGNAL(("rejected()")), self.reject)

        self.setTabOrder(self.mFontComboBox, self.mFontSizeSpinBox)
        self.setTabOrder(self.mFontSizeSpinBox, self.mBoldPushButton)
        self.setTabOrder(self.mBoldPushButton, self.mItalicsPushButton)
        self.setTabOrder(self.mItalicsPushButton, self.mFontColorButton)
        self.setTabOrder(self.mFontColorButton, self.mTextEdit)
        self.setTabOrder(self.mTextEdit, self.mButtonBox)

        self.setWindowTitle("Annotation text")
        self.mBoldPushButton.setText("B")
        self.mItalicsPushButton.setText("I")

        self.mTextDocument = None
        self.mItem = item
        self.mEmbeddedWidget = QgsAnnotationWidget(self, self.mItem)
        self.mEmbeddedWidget.show()
        self.mStackedWidget.addWidget(self.mEmbeddedWidget)
        self.mStackedWidget.setCurrentWidget(self.mEmbeddedWidget)
        if (self.mItem != None):
            self.mTextDocument = self.mItem.document()
            self.mTextEdit.setDocument(self.mTextDocument)
        self.mFontColorButton.setColorDialogTitle("Select font color")
        self.mFontColorButton.setColorDialogOptions(
            QColorDialog.ShowAlphaChannel)
        self.setCurrentFontPropertiesToGui()
        QObject.connect(self.mButtonBox, SIGNAL("accepted()"),
                        self.applyTextToItem)
        #         QObject.connect( self.mFontComboBox, SIGNAL( "currentFontChanged(QFont())"), self.changeCurrentFormat)
        self.mFontComboBox.currentFontChanged.connect(self.changeCurrentFormat)
        QObject.connect(self.mFontSizeSpinBox, SIGNAL("valueChanged( int )"),
                        self.changeCurrentFormat)
        QObject.connect(self.mBoldPushButton, SIGNAL("toggled( bool )"),
                        self.changeCurrentFormat)
        QObject.connect(self.mItalicsPushButton, SIGNAL("toggled( bool )"),
                        self.changeCurrentFormat)
        QObject.connect(self.mTextEdit, SIGNAL("cursorPositionChanged()"),
                        self.setCurrentFontPropertiesToGui)

        #         QObject.connect( self.mButtonBox, SIGNAL( "accepted()" ), self.applySettingsToItem)
        deleteButton = QPushButton("Delete")
        QObject.connect(deleteButton, SIGNAL("clicked()"), self.deleteItem)
        self.mButtonBox.addButton(deleteButton, QDialogButtonBox.RejectRole)

    def applyTextToItem(self):
        if (self.mItem != None and self.mTextDocument != None):
            if (self.mEmbeddedWidget != None):
                self.mEmbeddedWidget.apply()
            self.mItem.setDocument(self.mTextDocument)
            self.mItem.update()

    def changeCurrentFormat(self):
        newFont = QFont()
        newFont.setFamily(self.mFontComboBox.currentFont().family())
        #bold
        if (self.mBoldPushButton.isChecked()):
            newFont.setBold(True)
        else:
            newFont.setBold(False)
        #italic
        if (self.mItalicsPushButton.isChecked()):
            newFont.setItalic(True)
        else:
            newFont.setItalic(False)
        #size
        newFont.setPointSize(self.mFontSizeSpinBox.value())
        self.mTextEdit.setCurrentFont(newFont)
        #color
        self.mTextEdit.setTextColor(self.mFontColorButton.color())

    def on_mFontColorButton_colorChanged(self, color):
        self.changeCurrentFormat()

    def setCurrentFontPropertiesToGui(self):
        self.blockAllSignals(True)
        currentFont = self.mTextEdit.currentFont()
        self.mFontComboBox.setCurrentFont(currentFont)
        self.mFontSizeSpinBox.setValue(currentFont.pointSize())
        self.mBoldPushButton.setChecked(currentFont.bold())
        self.mItalicsPushButton.setChecked(currentFont.italic())
        self.mFontColorButton.setColor(self.mTextEdit.textColor())
        self.blockAllSignals(False)

    def blockAllSignals(self, block):
        self.mFontComboBox.blockSignals(block)
        self.mFontSizeSpinBox.blockSignals(block)
        self.mBoldPushButton.blockSignals(block)
        self.mItalicsPushButton.blockSignals(block)
        self.mFontColorButton.blockSignals(block)

    def deleteItem(self):
        scene = self.mItem.scene()
        if (scene != None):
            scene.removeItem(self.mItem)
        self.mItem = None
    def setupUi(self):
        self.labels = {}
        self.widgets = {}
        self.checkBoxes = {}
        self.showAdvanced = False
        self.valueItems = {}
        self.dependentItems = {}
        self.resize(650, 450)
        self.buttonBox = QDialogButtonBox()
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel
                                          | QDialogButtonBox.Ok)
        tooltips = self._alg.getParameterDescriptions()
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.verticalLayout = QVBoxLayout()
        self.verticalLayout.setSpacing(5)
        self.verticalLayout.setMargin(20)

        hLayout = QHBoxLayout()
        hLayout.setSpacing(5)
        hLayout.setMargin(0)
        descriptionLabel = QLabel(self.tr("Description"))
        self.descriptionBox = QLineEdit()
        self.descriptionBox.setText(self._alg.name)
        hLayout.addWidget(descriptionLabel)
        hLayout.addWidget(self.descriptionBox)
        self.verticalLayout.addLayout(hLayout)
        line = QFrame()
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)
        self.verticalLayout.addWidget(line)

        for param in self._alg.parameters:
            if param.isAdvanced:
                self.advancedButton = QPushButton()
                self.advancedButton.setText(
                    self.tr('Show advanced parameters'))
                self.advancedButton.setMaximumWidth(150)
                self.advancedButton.clicked.connect(
                    self.showAdvancedParametersClicked)
                self.verticalLayout.addWidget(self.advancedButton)
                break
        for param in self._alg.parameters:
            if param.hidden:
                continue
            desc = param.description
            if isinstance(param, ParameterExtent):
                desc += '(xmin, xmax, ymin, ymax)'
            label = QLabel(desc)
            self.labels[param.name] = label
            widget = self.getWidgetFromParameter(param)
            self.valueItems[param.name] = widget
            if param.name in tooltips.keys():
                tooltip = tooltips[param.name]
            else:
                tooltip = param.description
            label.setToolTip(tooltip)
            widget.setToolTip(tooltip)
            if param.isAdvanced:
                label.setVisible(self.showAdvanced)
                widget.setVisible(self.showAdvanced)
                self.widgets[param.name] = widget
            self.verticalLayout.addWidget(label)
            self.verticalLayout.addWidget(widget)

        for output in self._alg.outputs:
            if output.hidden:
                continue
            if isinstance(output, (OutputRaster, OutputVector, OutputTable,
                                   OutputHTML, OutputFile, OutputDirectory)):
                label = QLabel(output.description + '<' +
                               output.__class__.__name__ + '>')
                item = QLineEdit()
                if hasattr(item, 'setPlaceholderText'):
                    item.setPlaceholderText(ModelerParametersDialog.ENTER_NAME)
                self.verticalLayout.addWidget(label)
                self.verticalLayout.addWidget(item)
                self.valueItems[output.name] = item

        label = QLabel(' ')
        self.verticalLayout.addWidget(label)
        label = QLabel(self.tr('Parent algorithms'))
        self.dependenciesPanel = self.getDependenciesPanel()
        self.verticalLayout.addWidget(label)
        self.verticalLayout.addWidget(self.dependenciesPanel)

        self.verticalLayout.addStretch(1000)
        self.setLayout(self.verticalLayout)

        self.setPreviousValues()
        self.setWindowTitle(self._alg.name)
        self.verticalLayout2 = QVBoxLayout()
        self.verticalLayout2.setSpacing(2)
        self.verticalLayout2.setMargin(0)
        self.tabWidget = QTabWidget()
        self.tabWidget.setMinimumWidth(300)
        self.paramPanel = QWidget()
        self.paramPanel.setLayout(self.verticalLayout)
        self.scrollArea = QScrollArea()
        self.scrollArea.setWidget(self.paramPanel)
        self.scrollArea.setWidgetResizable(True)
        self.tabWidget.addTab(self.scrollArea, self.tr('Parameters'))
        self.webView = QWebView()

        html = None
        url = None
        isText, help = self._alg.help()
        if help is not None:
            if isText:
                html = help
            else:
                url = QUrl(help)
        else:
            html = self.tr('<h2>Sorry, no help is available for this '
                           'algorithm.</h2>')
        try:
            if html:
                self.webView.setHtml(html)
            elif url:
                self.webView.load(url)
        except:
            self.webView.setHtml(
                self.tr('<h2>Could not open help file :-( </h2>'))
        self.tabWidget.addTab(self.webView, 'Help')
        self.verticalLayout2.addWidget(self.tabWidget)
        self.verticalLayout2.addWidget(self.buttonBox)
        self.setLayout(self.verticalLayout2)
        self.buttonBox.accepted.connect(self.okPressed)
        self.buttonBox.rejected.connect(self.cancelPressed)
        QMetaObject.connectSlotsByName(self)
    def __init__(self, parent):
        super(EditorGeneral, self).__init__()
        self._preferences = parent
        vbox = QVBoxLayout(self)
        self.original_style = copy.copy(resources.CUSTOM_SCHEME)
        self.current_scheme = 'default'

        groupBoxMini = QGroupBox(
            translations.TR_PREFERENCES_EDITOR_GENERAL_MINIMAP)
        groupBoxTypo = QGroupBox(
            translations.TR_PREFERENCES_EDITOR_GENERAL_TYPOGRAPHY)
        groupBoxScheme = QGroupBox(
            translations.TR_PREFERENCES_EDITOR_GENERAL_SCHEME)

        #Minimap
        formMini = QGridLayout(groupBoxMini)
        self._checkShowMinimap = QCheckBox()
        self._spinMaxOpacity = QSpinBox()
        self._spinMaxOpacity.setMaximum(100)
        self._spinMaxOpacity.setMinimum(0)
        self._spinMinOpacity = QSpinBox()
        self._spinMinOpacity.setMaximum(100)
        self._spinMinOpacity.setMinimum(0)
        self._spinSize = QSpinBox()
        self._spinSize.setMaximum(100)
        self._spinSize.setMinimum(0)
        formMini.addWidget(
            QLabel(translations.TR_PREFERENCES_EDITOR_GENERAL_ENABLE_MINIMAP),
            0, 0, Qt.AlignRight)
        formMini.addWidget(
            QLabel(translations.TR_PREFERENCES_EDITOR_GENERAL_MAX_OPACITY), 1,
            0, Qt.AlignRight)
        formMini.addWidget(
            QLabel(translations.TR_PREFERENCES_EDITOR_GENERAL_MIN_OPACITY), 2,
            0, Qt.AlignRight)
        formMini.addWidget(
            QLabel(translations.TR_PREFERENCES_EDITOR_GENERAL_AREA_MINIMAP), 3,
            0, Qt.AlignRight)
        formMini.addWidget(self._checkShowMinimap, 0, 1)
        formMini.addWidget(self._spinMaxOpacity, 1, 1)
        formMini.addWidget(self._spinMinOpacity, 2, 1)
        formMini.addWidget(self._spinSize, 3, 1)
        #Typo
        gridTypo = QGridLayout(groupBoxTypo)
        self._btnEditorFont = QPushButton('')
        gridTypo.addWidget(
            QLabel(translations.TR_PREFERENCES_EDITOR_GENERAL_EDITOR_FONT), 0,
            0, Qt.AlignRight)
        gridTypo.addWidget(self._btnEditorFont, 0, 1)
        #Scheme
        hbox = QHBoxLayout(groupBoxScheme)
        self._listScheme = QListWidget()
        hbox.addWidget(self._listScheme)

        vbox.addWidget(groupBoxMini)
        vbox.addWidget(groupBoxTypo)
        vbox.addWidget(groupBoxScheme)

        #Settings
        qsettings = IDE.ninja_settings()
        qsettings.beginGroup('preferences')
        qsettings.beginGroup('editor')
        self._checkShowMinimap.setChecked(settings.SHOW_MINIMAP)
        self._spinMaxOpacity.setValue(settings.MINIMAP_MAX_OPACITY * 100)
        self._spinMinOpacity.setValue(settings.MINIMAP_MIN_OPACITY * 100)
        self._spinSize.setValue(settings.SIZE_PROPORTION * 100)
        self._btnEditorFont.setText(', '.join(
            [settings.FONT_FAMILY,
             str(settings.FONT_SIZE)]))
        self._listScheme.clear()
        self._listScheme.addItem('default')
        self._schemes = json_manager.load_editor_skins()
        for item in self._schemes:
            self._listScheme.addItem(item)
        items = self._listScheme.findItems(
            qsettings.value('scheme', defaultValue='', type='QString'),
            Qt.MatchExactly)
        if items:
            self._listScheme.setCurrentItem(items[0])
        else:
            self._listScheme.setCurrentRow(0)
        qsettings.endGroup()
        qsettings.endGroup()

        #Signals
        self.connect(self._btnEditorFont, SIGNAL("clicked()"),
                     self._load_editor_font)
        self.connect(self._listScheme, SIGNAL("itemSelectionChanged()"),
                     self._preview_style)
        self.connect(self._preferences, SIGNAL("savePreferences()"), self.save)
示例#41
0
    def initUI(self):
        self.setGeometry(200, 200, 250, 200)
        self.setWindowTitle(u'查找')

        title = QLabel(u'请选择搜索模式:')

        self.type_site_id = QRadioButton(u"基站ID ")
        self.type_site_id.setChecked(True)  # 默认查找基站ID
        self.type_site_name = QRadioButton(u"基站名 ")
        self.type_cell_id = QRadioButton(u"小区ID ")
        self.type_cell_name = QRadioButton(u"小区名 ")
        self.type_pn = QRadioButton(u"PN ")
        self.type_psc = QRadioButton(u"PSC ")
        self.type_pci = QRadioButton(u"PCI ")
        self.type_bcch = QRadioButton(u"BCCH ")

        search_type = QButtonGroup()
        search_type.addButton(self.type_site_id)
        search_type.addButton(self.type_site_name)
        search_type.addButton(self.type_cell_id)
        search_type.addButton(self.type_cell_name)
        search_type.addButton(self.type_pn)
        search_type.addButton(self.type_psc)
        search_type.addButton(self.type_pci)
        search_type.addButton(self.type_bcch)

        search_grid = QGridLayout()
        search_grid.setSpacing(10)
        search_grid.addWidget(self.type_site_id, 0, 1)
        search_grid.addWidget(self.type_site_name, 0, 2)
        search_grid.addWidget(self.type_cell_id, 0, 3)
        search_grid.addWidget(self.type_cell_name, 0, 4)
        search_grid.addWidget(self.type_pn, 1, 1)
        search_grid.addWidget(self.type_psc, 1, 2)
        search_grid.addWidget(self.type_pci, 1, 3)
        search_grid.addWidget(self.type_bcch, 1, 4)

        search_hbox = QHBoxLayout()
        search_hbox.setSpacing(10)
        search_hbox.addStretch(1)
        search_hbox.addLayout(search_grid)
        search_hbox.addStretch(1)

        self.searchText = QLineEdit()
        ok = QPushButton(u'确定')
        self.connect(ok, SIGNAL('clicked()'), self.search)
        cancel = QPushButton(u'取消')
        self.connect(cancel, SIGNAL('clicked()'), self.cancel)

        btn_hbox = QHBoxLayout()
        btn_hbox.setSpacing(10)
        btn_hbox.addStretch(1)
        btn_hbox.addWidget(ok)
        btn_hbox.addWidget(cancel)
        btn_hbox.addStretch(1)

        vbox = QVBoxLayout()
        vbox.setSpacing(15)
        vbox.addWidget(title)
        vbox.addLayout(search_hbox)
        vbox.addWidget(self.searchText)
        vbox.addStretch(1)
        vbox.addLayout(btn_hbox)

        self.setLayout(vbox)
        self.resize(350, 190)
示例#42
0
    def __init__(self):
        super().__init__()

        #: input data
        self.data = None
        #: Current variable discretization state
        self.var_state = {}
        #: Saved variable discretization settings (context setting)
        self.saved_var_states = {}

        self.method = 0
        self.k = 5

        box = gui.vBox(self.controlArea, self.tr("Default Discretization"))
        self.default_bbox = rbox = gui.radioButtons(
            box, self, "default_method", callback=self._default_disc_changed)

        options = self.options = [
            self.tr("Default"),
            self.tr("Leave numeric"),
            self.tr("Entropy-MDL discretization"),
            self.tr("Equal-frequency discretization"),
            self.tr("Equal-width discretization"),
            self.tr("Remove numeric variables")
        ]

        for opt in options[1:5]:
            gui.appendRadioButton(rbox, opt)

        s = gui.hSlider(gui.indentedBox(rbox),
                        self,
                        "default_k",
                        minValue=2,
                        maxValue=10,
                        label="Num. of intervals:",
                        callback=self._default_disc_changed)
        s.setTracking(False)

        gui.appendRadioButton(rbox, options[-1])

        vlayout = QHBoxLayout()
        box = gui.widgetBox(self.controlArea,
                            "Individual Attribute Settings",
                            orientation=vlayout,
                            spacing=8)

        # List view with all attributes
        self.varview = QListView(selectionMode=QListView.ExtendedSelection)
        self.varview.setItemDelegate(DiscDelegate())
        self.varmodel = itemmodels.VariableListModel()
        self.varview.setModel(self.varmodel)
        self.varview.selectionModel().selectionChanged.connect(
            self._var_selection_changed)

        vlayout.addWidget(self.varview)
        # Controls for individual attr settings
        self.bbox = controlbox = gui.radioButtons(
            box, self, "method", callback=self._disc_method_changed)
        vlayout.addWidget(controlbox)

        for opt in options[:5]:
            gui.appendRadioButton(controlbox, opt)

        s = gui.hSlider(gui.indentedBox(controlbox),
                        self,
                        "k",
                        minValue=2,
                        maxValue=10,
                        label="Num. of intervals:",
                        callback=self._disc_method_changed)
        s.setTracking(False)

        gui.appendRadioButton(controlbox, "Remove attribute")

        gui.rubber(controlbox)
        controlbox.setEnabled(False)

        self.controlbox = controlbox

        box = gui.auto_commit(self.controlArea,
                              self,
                              "autosend",
                              "Apply",
                              orientation=Qt.Horizontal,
                              checkbox_label="Apply automatically")
        box.layout().insertSpacing(0, 20)
        box.layout().insertWidget(0, self.report_button)
示例#43
0
class CartoDBToolbar(QWidget):
    error = pyqtSignal(object)

    def __init__(self, parent=None, flags=Qt.WindowFlags(0)):
        QWidget.__init__(self, parent, flags)
        self.settings = QSettings()
        self.setupUi()
        self.currentUser = self.settings.value('/CartoDBPlugin/selected')

        if self.currentUser:
            self.currentApiKey = self.settings.value('/CartoDBPlugin/%s/api' %
                                                     self.currentUser)
            self.currentMultiuser = self.settings.value(
                '/CartoDBPlugin/%s/multiuser' % self.currentUser, False)
            self.currentMultiuser = self.currentMultiuser in [
                'True', 'true', True
            ]
        else:
            self.currentApiKey = None
            self.currentMultiuser = None

        self.click = None

    def setupUi(self):
        self.connectLayout = QHBoxLayout(self)
        self.connectLayout.setSizeConstraint(QLayout.SetDefaultConstraint)
        self.avatarLB = QLabel(self)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.avatarLB.sizePolicy().hasHeightForWidth())
        self.avatarLB.setSizePolicy(sizePolicy)
        self.avatarLB.setFixedSize(24, 24)
        self.avatarLB.hide()

        self.nameLB = QLabel(self)
        self.nameLB.setFocusPolicy(Qt.ClickFocus)
        self.nameLB.setTextFormat(Qt.RichText)
        self.nameLB.setText(
            "<html><head/><body><p><span style=\"text-decoration: underline; color:#00557f;\">Add Connection</span></p></body></html>"
        )

        self.setCursor(QCursor(Qt.PointingHandCursor))
        self.connectLayout.addWidget(self.avatarLB)
        self.connectLayout.addWidget(self.nameLB)

    def getUserData(self, cartodbUser, apiKey, multiuser=False):
        cartoDBApi = CartoDBApi(cartodbUser, apiKey, multiuser)
        cartoDBApi.fetchContent.connect(self.cbUserData)
        cartoDBApi.getUserDetails()

    @pyqtSlot(dict)
    def cbUserData(self, data):
        if 'error' in data:
            # TODO Create image for error
            self.nameLB.setText(
                "<html><head/><body><p><span style=\" text-decoration: underline; color:red;\">error</span></p></body></html>"
            )
            self.error.emit(data['error'])
            return

        self.currentUserData = data
        self.settings.setValue('/CartoDBPlugin/selected', self.currentUser)
        manager = QNetworkAccessManager()
        manager.finished.connect(self.returnAvatar)

        if 's3.amazonaws.com' in data['avatar_url']:
            imageUrl = QUrl(data['avatar_url'])
        else:
            imageUrl = QUrl('http:' + data['avatar_url'])

        request = QNetworkRequest(imageUrl)
        request.setRawHeader('User-Agent', 'QGIS 2.x')
        reply = manager.get(request)
        loop = QEventLoop()
        reply.finished.connect(loop.exit)
        loop.exec_()

    def returnAvatar(self, reply):
        imageReader = QImageReader(reply)
        self.avatarImage = imageReader.read()

        lbl = self.avatarLB
        if reply.error() == QNetworkReply.NoError:
            pixMap = QPixmap.fromImage(self.avatarImage).scaled(
                lbl.size(), Qt.KeepAspectRatio)
            lbl.setPixmap(pixMap)
            lbl.show()
        else:
            # TODO Put default image if not load from URL.
            pass

        self.nameLB.setText(
            "<html><head/><body><p><span style=\" text-decoration: underline; color:#00557f;\">"
            + self.currentUser + "</span></p></body></html>")
        # self.setUpUserData()

    @pyqtSlot()
    def connectCartoDB(self):
        if self.isCurrentUserValid():
            self.getUserData(self.currentUser, self.currentApiKey,
                             self.currentMultiuser)

    def setUserCredentials(self, user, apiKey, multiuser=False):
        self.currentUser = user
        self.currentApiKey = apiKey
        self.currentMultiuser = multiuser
        worker = CartoDBPluginWorker(self, 'connectCartoDB')
        worker.start()

    def isCurrentUserValid(self):
        return self.currentUser is not None and self.currentApiKey is not None

    def mousePressEvent(self, event):
        if self.click is not None:
            self.click()

    def setClick(self, click):
        self.click = click

    def setConnectText(self):
        # TODO Create image for connect text
        self.avatarLB.hide()
        self.nameLB.setText(
            "<html><head/><body><p><span style=\"text-decoration: underline; color:#00557f;\">Connect</span></p></body></html>"
        )

    def reset(self):
        # TODO Create image for add connection
        self.avatarLB.hide()
        self.nameLB.setText(
            "<html><head/><body><p><span style=\"text-decoration: underline; color:#00557f;\">Add Connection</span></p></body></html>"
        )
示例#44
0
class FileSelectionWidget(QWidget):
    def __init__(self, parent=None):
        super(FileSelectionWidget, self).__init__(None)
        self.setupUi(self)

        self.ext = '*'
        self.dialog_title = self.tr('Select folder')
        self.is_folder = False

        self.btnSelect.clicked.connect(self.show_selection_dialog)

    def show_selection_dialog(self):
        # Find the file dialog's working directory
        settings = QSettings()
        text = self.leText.text()
        if os.path.isdir(text):
            path = text
        elif os.path.isdir(os.path.dirname(text)):
            path = os.path.dirname(text)
        else:
            path = PluginSettings.last_icon_path()

        if self.is_folder:
            folder = QFileDialog.getExistingDirectory(self, self.dialog_title,
                                                      path)
            if folder:
                self.leText.setText(folder)
                PluginSettings.set_last_icon_path(os.path.dirname(folder))
        else:
            filename = QFileDialog.getOpenFileName(self, self.dialog_title,
                                                   path, self.ext)
            if filename:
                self.leText.setText(filename)
                PluginSettings.set_last_icon_path(os.path.dirname(filename))

    def get_path(self):
        s = self.leText.text()
        if os.name == 'nt':
            s = s.replace('\\', '/')
        return s

    def set_path(self, text):
        self.leText.setText(text)

    def set_dialog_ext(self, ext):
        self.ext = ext

    def set_dialog_title(self, title):
        self.dialog_titledialog_title = title

    def setupUi(self, Form):
        Form.setObjectName(_fromUtf8("Form"))
        Form.resize(249, 23)
        self.horizontalLayout = QHBoxLayout(Form)
        self.horizontalLayout.setSpacing(2)
        self.horizontalLayout.setMargin(0)
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        self.leText = QLineEdit(Form)
        self.leText.setReadOnly(True)
        self.leText.setObjectName(_fromUtf8("leText"))
        self.horizontalLayout.addWidget(self.leText)
        self.btnSelect = QToolButton(Form)
        self.btnSelect.setObjectName(_fromUtf8("btnSelect"))
        self.horizontalLayout.addWidget(self.btnSelect)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        #Form.setWindowTitle(self.tr(self.dialog_title))
        self.btnSelect.setText(self.tr("..."))
示例#45
0
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        self._parent = parent
        hSearch = QHBoxLayout(self)
        hSearch.setContentsMargins(0, 0, 0, 0)
        self._checkSensitive = QCheckBox(self.tr("Respect Case Sensitive"))
        self._checkWholeWord = QCheckBox(self.tr("Find Whole Words"))
        self._line = TextLine(self)
        self._line.setMinimumWidth(250)
        self._btnClose = QPushButton(
            self.style().standardIcon(QStyle.SP_DialogCloseButton), '')
        self._btnFind = QPushButton(QIcon(resources.IMAGES['find']), '')
        self.btnPrevious = QPushButton(
            self.style().standardIcon(QStyle.SP_ArrowLeft), '')
        self.btnPrevious.setToolTip(
            self.tr("Press %1").arg(
                resources.get_shortcut("Find-previous").toString(
                    QKeySequence.NativeText)))
        self.btnNext = QPushButton(
            self.style().standardIcon(QStyle.SP_ArrowRight), '')
        self.btnNext.setToolTip(
            self.tr("Press %1").arg(
                resources.get_shortcut("Find-next").toString(
                    QKeySequence.NativeText)))
        hSearch.addWidget(self._btnClose)
        hSearch.addWidget(self._line)
        hSearch.addWidget(self._btnFind)
        hSearch.addWidget(self.btnPrevious)
        hSearch.addWidget(self.btnNext)
        hSearch.addWidget(self._checkSensitive)
        hSearch.addWidget(self._checkWholeWord)

        self.totalMatches = 0
        self.index = 0
        self._line.counter.update_count(self.index, self.totalMatches)

        self.connect(self._btnClose, SIGNAL("clicked()"),
                     self._parent.hide_status)
        self.connect(self._btnFind, SIGNAL("clicked()"), self.find_next)
        self.connect(self.btnNext, SIGNAL("clicked()"), self.find_next)
        self.connect(self.btnPrevious, SIGNAL("clicked()"), self.find_previous)
        self.connect(self._checkSensitive, SIGNAL("stateChanged(int)"),
                     self._checks_state_changed)
        self.connect(self._checkWholeWord, SIGNAL("stateChanged(int)"),
                     self._checks_state_changed)
示例#46
0
    def __init__(self, parent=None):
        super().__init__(parent=parent)

        # cost display
        self.cost = QGroupBox("National ideas")
        costLayout = QFormLayout()

        self.costRating = QLineEdit()
        self.costRating.setReadOnly(True)
        costLayout.addRow(QLabel("Rating:"), self.costRating)

        self.costDisplay = QLineEdit()
        self.costDisplay.setReadOnly(True)
        costLayout.addRow(QLabel("Cost:"), self.costDisplay)

        possibleRatings = QGroupBox("Possible ratings")
        possibleRatingsLayout = QFormLayout()
        for cost, rating in ideaRatings:
            if cost is not None:
                possibleRatingsLayout.addRow(QLabel("Up to %0.1f:" % (cost),), QLabel(rating))
            else:
                possibleRatingsLayout.addRow(QLabel("Above:"), QLabel(rating))
        possibleRatings.setLayout(possibleRatingsLayout)
        costLayout.addRow(possibleRatings)

        breakdown = QGroupBox("Breakdown")
        breakdownLayout = QFormLayout()
        self.breakdownLabels = []
        self.breakdownCosts = []
        for i in range(9):
            breakdownLabel = QLabel()
            self.breakdownLabels.append(breakdownLabel)
            
            breakdownCost = QLineEdit()
            breakdownCost.setReadOnly(True)
            
            self.breakdownCosts.append(breakdownCost)
            breakdownLayout.addRow(breakdownLabel, breakdownCost)

        breakdown.setLayout(breakdownLayout)

        costLayout.addRow(breakdown)

        self.cost.setLayout(costLayout)

        self.cost.setToolTip(costToolTipText)

        # penalty display
        self.penalties = QGroupBox("Penalties")
        penaltiesLayout = QFormLayout()

        # self.penaltiesRating = QLineEdit()
        # self.penaltiesRating.setReadOnly(True)
        # penaltiesLayout.addRow(QLabel("Rating:"), self.penaltiesRating)
        
        self.yellowCardCount = QLineEdit()
        self.yellowCardCount.setReadOnly(True)
        penaltiesLayout.addRow(QLabel("Yellow cards:"), self.yellowCardCount)

        self.yellowCardDisplay = QListView()
        self.yellowCardDisplay.setSelectionMode(QAbstractItemView.NoSelection)
        self.yellowCards = QStringListModel()
        self.yellowCardDisplay.setModel(self.yellowCards)
        penaltiesLayout.addRow(self.yellowCardDisplay)

        self.redCardCount = QLineEdit()
        self.redCardCount.setReadOnly(True)
        penaltiesLayout.addRow(QLabel("Red cards:"), self.redCardCount)

        self.redCardDisplay = QListView()
        self.redCardDisplay.setSelectionMode(QAbstractItemView.NoSelection)
        self.redCards = QStringListModel()
        self.redCardDisplay.setModel(self.redCards)
        penaltiesLayout.addRow(self.redCardDisplay)

        self.penalties.setLayout(penaltiesLayout)

        self.penalties.setToolTip(penaltiesToolTipText)

        layout = QHBoxLayout()

        layout.addWidget(self.cost)
        layout.addWidget(self.penalties)

        self.setLayout(layout)
示例#47
0
    def setup_page(self):
        run_dlg = _("Run Settings")
        run_menu = _("Run")
        about_label = QLabel(_("The following are the default <i>%s</i>. "\
                               "These options may be overriden using the "\
                               "<b>%s</b> dialog box (see the <b>%s</b> menu)"\
                               ) % (run_dlg, run_dlg, run_menu))
        about_label.setWordWrap(True)

        interpreter_group = QGroupBox(_("Interpreter"))
        interpreter_bg = QButtonGroup(interpreter_group)
        self.current_radio = self.create_radiobutton(
            CURRENT_INTERPRETER,
            CURRENT_INTERPRETER_OPTION,
            True,
            button_group=interpreter_bg)
        self.dedicated_radio = self.create_radiobutton(
            DEDICATED_INTERPRETER,
            DEDICATED_INTERPRETER_OPTION,
            False,
            button_group=interpreter_bg)
        self.systerm_radio = self.create_radiobutton(
            SYSTERM_INTERPRETER,
            SYSTERM_INTERPRETER_OPTION,
            False,
            button_group=interpreter_bg)

        interpreter_layout = QVBoxLayout()
        interpreter_group.setLayout(interpreter_layout)
        interpreter_layout.addWidget(self.current_radio)
        interpreter_layout.addWidget(self.dedicated_radio)
        interpreter_layout.addWidget(self.systerm_radio)

        wdir_group = QGroupBox(_("Working directory"))
        wdir_bg = QButtonGroup(wdir_group)
        wdir_label = QLabel(_("Default working directory is:"))
        wdir_label.setWordWrap(True)
        dirname_radio = self.create_radiobutton(_("the script directory"),
                                                WDIR_USE_SCRIPT_DIR_OPTION,
                                                True,
                                                button_group=wdir_bg)
        thisdir_radio = self.create_radiobutton(_("the following directory:"),
                                                WDIR_USE_FIXED_DIR_OPTION,
                                                False,
                                                button_group=wdir_bg)
        thisdir_bd = self.create_browsedir("", WDIR_FIXED_DIR_OPTION,
                                           os.getcwdu())
        self.connect(thisdir_radio, SIGNAL("toggled(bool)"),
                     thisdir_bd.setEnabled)
        self.connect(dirname_radio, SIGNAL("toggled(bool)"),
                     thisdir_bd.setDisabled)
        thisdir_layout = QHBoxLayout()
        thisdir_layout.addWidget(thisdir_radio)
        thisdir_layout.addWidget(thisdir_bd)

        wdir_layout = QVBoxLayout()
        wdir_layout.addWidget(wdir_label)
        wdir_layout.addWidget(dirname_radio)
        wdir_layout.addLayout(thisdir_layout)
        wdir_group.setLayout(wdir_layout)

        firstrun_cb = self.create_checkbox(
            ALWAYS_OPEN_FIRST_RUN % _("Run Settings dialog"),
            ALWAYS_OPEN_FIRST_RUN_OPTION, False)

        vlayout = QVBoxLayout()
        vlayout.addWidget(about_label)
        vlayout.addSpacing(10)
        vlayout.addWidget(interpreter_group)
        vlayout.addWidget(wdir_group)
        vlayout.addWidget(firstrun_cb)
        vlayout.addStretch(1)
        self.setLayout(vlayout)
示例#48
0
文件: ptc.py 项目: fscherwi/brickv
    def __init__(self, *args):
        PluginBase.__init__(self, BrickletPTC, *args)

        self.ptc = self.device

        self.str_connected = 'Sensor is currently <font color="green">connected</font>'
        self.str_not_connected = 'Sensor is currently <font color="red">not connected</font>'

        self.cbe_temperature = CallbackEmulator(self.ptc.get_temperature,
                                                self.cb_temperature,
                                                self.increase_error_count)

        #        self.cbe_resistance = CallbackEmulator(self.ptc.get_resistance,
        #                                               self.cb_resistance,
        #                                               self.increase_error_count)

        self.temperature_label = TemperatureLabel()
        #        self.resistance_label = ResistanceLabel()

        self.wire_label = QLabel('Wire Type:')
        self.wire_combo = QComboBox()
        self.wire_combo.addItem('2-Wire')
        self.wire_combo.addItem('3-Wire')
        self.wire_combo.addItem('4-Wire')

        self.noise_label = QLabel('Noise Rejection Filter:')
        self.noise_combo = QComboBox()
        self.noise_combo.addItem('50Hz')
        self.noise_combo.addItem('60Hz')

        self.connected_label = QLabel(self.str_connected)

        self.current_value = None

        self.wire_combo.currentIndexChanged.connect(
            self.wire_combo_index_changed)
        self.noise_combo.currentIndexChanged.connect(
            self.noise_combo_index_changed)

        plot_list = [['', Qt.red, self.get_current_value]]
        self.plot_widget = PlotWidget('Temperature [%cC]' % 0xB0, plot_list)

        layout_h = QHBoxLayout()
        layout_h.addStretch()
        layout_h.addWidget(self.temperature_label)
        layout_h.addStretch()
        layout_h.addWidget(self.connected_label)
        layout_h.addStretch()

        layout_h2 = QHBoxLayout()
        layout_h2.addWidget(self.wire_label)
        layout_h2.addWidget(self.wire_combo)
        layout_h2.addStretch()
        layout_h2.addWidget(self.noise_label)
        layout_h2.addWidget(self.noise_combo)

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h)
        layout.addWidget(self.plot_widget)
        layout.addLayout(layout_h2)

        self.connected_timer = QTimer()
        self.connected_timer.timeout.connect(self.update_connected)
        self.connected_timer.setInterval(1000)
示例#49
0
class MainWindow(QMainWindow):
    def __init__(self, app):
        ''' Constructor '''
        super(MainWindow, self).__init__()

        self.app = app
        self.power_on = False
        self.power_state_string = "Power is OFF"
        pixmap = QPixmap("towerpowericon.png")
        self.setWindowIcon(QIcon(pixmap))

        self.version = "1.0.2"

        self.setWindowTitle("Tower Power Supply GUI %s" % self.version)
        self.setGeometry(100, 100, 360, 100)

        self.power_supplies = tower_power_supplies.TowerPowerSupplies()

        self.central_widget = QWidget(self)
        self.setCentralWidget(self.central_widget)

        self.layout_widget = QWidget(self.central_widget)
        self.layout = QVBoxLayout(self.central_widget)

        self.top_text_label = QLabel("Tower Power Supply Control",
                                     self.central_widget)
        psa_text = "Power Supply A: %s %s (pad=%s)" % \
            (self.power_supplies.power_supply_1.manufacturer,
             self.power_supplies.power_supply_1.model_number,
             str(self.power_supplies.power_supply_1.pad))
        self.psa_label = QLabel(psa_text, self.central_widget)
        psb_text = "Power Supply B: %s %s (pad=%s)" % \
            (self.power_supplies.power_supply_2.manufacturer,
             self.power_supplies.power_supply_2.model_number,
             str(self.power_supplies.power_supply_2.pad))
        self.psb_label = QLabel(psb_text, self.central_widget)
        self.power_state_label = QLabel(self.power_state_string,
                                        self.central_widget)
        self.power_on_button = QPushButton("Power ON", self.central_widget)
        self.power_off_button = QPushButton("Power OFF", self.central_widget)
        self.quit_button = QPushButton("Quit", self.central_widget)
        self.readingLabel = QLabel("no readings yet", self.central_widget)

        self.buttons_layout_widget = QWidget(self.central_widget)
        self.buttons_layout = QHBoxLayout(self.buttons_layout_widget)

        self.layout.addWidget(self.top_text_label, 0, Qt.AlignHCenter)
        self.layout.addWidget(self.psa_label)
        self.layout.addWidget(self.psb_label)
        self.layout.addWidget(self.buttons_layout_widget)
        self.layout.addWidget(self.power_state_label, 0, Qt.AlignHCenter)
        self.layout.addWidget(self.readingLabel)
        # self.readingLabel.setPixmap(pixmap) # test that the pixmap was loaded

        self.buttons_layout.addWidget(self.power_on_button)
        self.buttons_layout.addWidget(self.power_off_button)
        self.buttons_layout.addWidget(self.quit_button)

        self.connect(self.power_on_button, SIGNAL("clicked()"),
                     self.power_on_event)
        self.connect(self.power_off_button, SIGNAL("clicked()"),
                     self.power_off_event)
        self.connect(self.quit_button, SIGNAL("clicked()"), self.quit_event)

        # Update the state of the power supplies
        self.updatePowerOnString()

    def power_on_event(self):

        s = self.power_supplies.powerOnSequence()
        self.updatePowerOnString()
        self.readingLabel.setText("most recent readings:\n" + s)

    def power_off_event(self):

        self.power_supplies.powerOffSupplies()
        self.updatePowerOnString()

    def quit_event(self):

        self.app.quit()

    def updatePowerOnString(self):

        if self.power_supplies.powered == True:
            self.power_state_string = "Power is ON"
        else:
            self.power_state_string = "Power is OFF"
        self.power_state_label.setText(self.power_state_string)
示例#50
0
    def __init__(self, parent=None):

        'Vererbung aller Attribute und Methoden von QWidget'
        super(DigitalerRoboter, self).__init__(parent)

        'Zeichenflächen mit Koordinatensystem instanziieren'

        'Hintergrundfarbe der Zeichenflächen festlegen'
        farbe_zeichenflaeche = '#b5afb5'

        'Zeichenfläche mit Koordinatensystem instanziieren - Draufsicht'
        self.zeichenflaeche_draufsicht = QPlotWidget()

        #Hintergrundfarbe festlegen
        self.zeichenflaeche_draufsicht.figure.set_facecolor( \
        farbe_zeichenflaeche)

        #Koordinatensystem an die Zeichenfläche anpassen
        self.zeichenflaeche_draufsicht.figure.tight_layout()

        #gleiche Skalierung der Achsen des Koordinatensystems
        self.zeichenflaeche_draufsicht.axes.set_aspect('equal')

        #Grenzen des Koordinatensystems festlegen
        self.zeichenflaeche_draufsicht.axes.set_xlim([-650, 650])
        self.zeichenflaeche_draufsicht.axes.set_ylim([-225, 625])

        #Achsen des Koordinatensystems und Beschriftung ausblenden
        self.zeichenflaeche_draufsicht.axes.axis('off')

        #Zeichenfläche deaktivieren
        self.zeichenflaeche_draufsicht.setEnabled(False)

        'Zeichenfläche mit Koordinatensystem instanziieren - Seitenansicht'
        self.zeichenflaeche_seitenansicht = QPlotWidget()

        #Hintergrundfarbe festlegen
        self.zeichenflaeche_seitenansicht.figure.set_facecolor( \
        farbe_zeichenflaeche)

        #Koordinatensystem an die Zeichenfläche anpassen
        self.zeichenflaeche_seitenansicht.figure.tight_layout()

        #gleiche Skalierung der Achsen des Koordinatensystems
        self.zeichenflaeche_seitenansicht.axes.set_aspect('equal')

        #Grenzen des Koordinatensystems festlegen
        self.zeichenflaeche_seitenansicht.axes.set_xlim(-250, 650)
        self.zeichenflaeche_seitenansicht.axes.set_ylim([-225, 625])

        #Achsen des Koordinatensystems und Beschriftung ausblenden
        self.zeichenflaeche_seitenansicht.axes.axis('off')

        #Zeichenfläche deaktivieren
        self.zeichenflaeche_seitenansicht.setEnabled(False)

        'Zeichenfläche mit Koordinatensystem instanziieren - Greifer'
        self.zeichenflaeche_ansicht_greifer = QPlotWidget()

        #Hintergrundfarbe festlegen
        self.zeichenflaeche_ansicht_greifer.figure.set_facecolor( \
        farbe_zeichenflaeche)

        #Koordinatensystem an die Zeichenfläche anpassen
        self.zeichenflaeche_ansicht_greifer.figure.tight_layout()

        #gleiche Skalierung der Achsen des Koordinatensystems
        self.zeichenflaeche_ansicht_greifer.axes.set_aspect('equal')

        #Grenzen des Koordinatensystems festlegen
        self.zeichenflaeche_ansicht_greifer.axes.set_xlim([-350, 350])
        self.zeichenflaeche_ansicht_greifer.axes.set_ylim([-350, 350])

        #Achsen des Koordinatensystems und Beschriftung ausblenden
        self.zeichenflaeche_ansicht_greifer.axes.axis('off')

        #Zeichenfläche deaktivieren
        self.zeichenflaeche_ansicht_greifer.setEnabled(False)
        '''Die Zeichenflächen werden gestapelt, da immer nur eine
        Ansicht angezeigt werden kann.'''

        'QStackedWidget-Objekt instanziieren'
        self.ansicht = QStackedWidget()
        #Draufischt: CurrentIndex(0)
        self.ansicht.addWidget(self.zeichenflaeche_draufsicht)
        #Seitenansicht: CurrentIndex(1)
        self.ansicht.addWidget(self.zeichenflaeche_seitenansicht)
        #Greifer: CurrentIndex(2)
        self.ansicht.addWidget(self.zeichenflaeche_ansicht_greifer)

        'Layout festlegen'
        layout = QHBoxLayout()
        layout.addWidget(self.ansicht)
        self.setLayout(layout)
        '''Lage und Orientierung des Werkzeugkoordinatensystem sowie die
        Öffnungsradien des Greifers in Ausgangsposition laden'''

        'Denavit-Hartenberg-Parameter laden'
        (d1, d2, d3, d4, d5, a1, a2, a3, a4, a5, \
        alpha1, alpha2, alpha3, alpha4, alpha5) = denavit_hartenberg()
        self.a3 = a3

        'Orientierung des Werkzeugkoordinatensystems laden'
        self.x5in0, self.y5in0, self.z5in0 = \
        self.orientierung_laden('programmEin')

        'Lagevektor des Werkzeugkoordinatensystems laden'
        self.P05in0 = self.lage_laden('programmEin')

        'Öffnungsradien des Greifers laden'
        self.r6, self.r7 = self.greifer_laden('programmEin')

        'Mittelpunktkoordinaten der Punkte berechnen'
        self.modellrechnung()

        'Methode animation_anzeigen aufrufen'
        self.animation_anzeigen()
示例#51
0
    def __createLayout(self, scriptName, name, code, reportTime):
        " Creates the toolbar and layout "

        # Buttons
        self.__printButton = QAction(PixmapCache().getIcon('printer.png'),
                                     'Print', self)
        self.__printButton.triggered.connect(self.__onPrint)
        self.__printButton.setEnabled(False)
        self.__printButton.setVisible(False)

        self.__printPreviewButton = QAction(
            PixmapCache().getIcon('printpreview.png'), 'Print preview', self)
        self.__printPreviewButton.triggered.connect(self.__onPrintPreview)
        self.__printPreviewButton.setEnabled(False)
        self.__printPreviewButton.setVisible(False)

        # Zoom buttons
        self.__zoomInButton = QAction(PixmapCache().getIcon('zoomin.png'),
                                      'Zoom in (Ctrl+=)', self)
        self.__zoomInButton.triggered.connect(self.onZoomIn)

        self.__zoomOutButton = QAction(PixmapCache().getIcon('zoomout.png'),
                                       'Zoom out (Ctrl+-)', self)
        self.__zoomOutButton.triggered.connect(self.onZoomOut)

        self.__zoomResetButton = QAction(
            PixmapCache().getIcon('zoomreset.png'), 'Zoom reset (Ctrl+0)',
            self)
        self.__zoomResetButton.triggered.connect(self.onZoomReset)

        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        # Toolbar
        toolbar = QToolBar(self)
        toolbar.setOrientation(Qt.Vertical)
        toolbar.setMovable(False)
        toolbar.setAllowedAreas(Qt.RightToolBarArea)
        toolbar.setIconSize(QSize(16, 16))
        toolbar.setFixedWidth(28)
        toolbar.setContentsMargins(0, 0, 0, 0)

        toolbar.addAction(self.__printPreviewButton)
        toolbar.addAction(self.__printButton)
        toolbar.addWidget(spacer)
        toolbar.addAction(self.__zoomInButton)
        toolbar.addAction(self.__zoomOutButton)
        toolbar.addAction(self.__zoomResetButton)

        summary = QLabel("<b>Script:</b> " + scriptName + "<br>"
                         "<b>Name:</b> " + name + "<br>"
                         "<b>Disassembled at:</b> " + reportTime)
        summary.setFrameStyle(QFrame.StyledPanel)
        summary.setAutoFillBackground(True)
        summaryPalette = summary.palette()
        summaryBackground = summaryPalette.color(QPalette.Background)
        summaryBackground.setRgb(min(summaryBackground.red() + 30, 255),
                                 min(summaryBackground.green() + 30, 255),
                                 min(summaryBackground.blue() + 30, 255))
        summaryPalette.setColor(QPalette.Background, summaryBackground)
        summary.setPalette(summaryPalette)

        self.__text = DisasmWidget(self)
        self.__text.setAcceptRichText(False)
        self.__text.setLineWrapMode(QTextEdit.NoWrap)
        self.__text.setFont(GlobalData().skin.nolexerFont)
        self.zoomTo(Settings().zoom)
        self.__text.setReadOnly(True)
        self.__text.setPlainText(code)

        vLayout = QVBoxLayout()
        vLayout.addWidget(summary)
        vLayout.addWidget(self.__text)

        hLayout = QHBoxLayout()
        hLayout.setContentsMargins(0, 0, 0, 0)
        hLayout.setSpacing(0)
        hLayout.addLayout(vLayout)
        hLayout.addWidget(toolbar)

        self.setLayout(hLayout)
        return
示例#52
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.current_radio = None
        self.dedicated_radio = None
        self.systerm_radio = None

        self.runconf = RunConfiguration()

        firstrun_o = CONF.get('run', ALWAYS_OPEN_FIRST_RUN_OPTION, False)

        # --- General settings ----
        common_group = QGroupBox(_("General settings"))
        common_layout = QGridLayout()
        common_group.setLayout(common_layout)
        self.clo_cb = QCheckBox(_("Command line options:"))
        common_layout.addWidget(self.clo_cb, 0, 0)
        self.clo_edit = QLineEdit()
        self.connect(self.clo_cb, SIGNAL("toggled(bool)"),
                     self.clo_edit.setEnabled)
        self.clo_edit.setEnabled(False)
        common_layout.addWidget(self.clo_edit, 0, 1)
        self.wd_cb = QCheckBox(_("Working directory:"))
        common_layout.addWidget(self.wd_cb, 1, 0)
        wd_layout = QHBoxLayout()
        self.wd_edit = QLineEdit()
        self.connect(self.wd_cb, SIGNAL("toggled(bool)"),
                     self.wd_edit.setEnabled)
        self.wd_edit.setEnabled(False)
        wd_layout.addWidget(self.wd_edit)
        browse_btn = QPushButton(get_std_icon('DirOpenIcon'), "", self)
        browse_btn.setToolTip(_("Select directory"))
        self.connect(browse_btn, SIGNAL("clicked()"), self.select_directory)
        wd_layout.addWidget(browse_btn)
        common_layout.addLayout(wd_layout, 1, 1)

        # --- Interpreter ---
        interpreter_group = QGroupBox(_("Interpreter"))
        interpreter_layout = QVBoxLayout()
        interpreter_group.setLayout(interpreter_layout)
        self.current_radio = QRadioButton(CURRENT_INTERPRETER)
        interpreter_layout.addWidget(self.current_radio)
        self.dedicated_radio = QRadioButton(DEDICATED_INTERPRETER)
        interpreter_layout.addWidget(self.dedicated_radio)
        self.systerm_radio = QRadioButton(SYSTERM_INTERPRETER)
        interpreter_layout.addWidget(self.systerm_radio)

        # --- Dedicated interpreter ---
        new_group = QGroupBox(_("Dedicated Python interpreter"))
        self.connect(self.current_radio, SIGNAL("toggled(bool)"),
                     new_group.setDisabled)
        new_layout = QGridLayout()
        new_group.setLayout(new_layout)
        self.interact_cb = QCheckBox(
            _("Interact with the Python "
              "interpreter after execution"))
        new_layout.addWidget(self.interact_cb, 1, 0, 1, -1)
        self.pclo_cb = QCheckBox(_("Command line options:"))
        new_layout.addWidget(self.pclo_cb, 2, 0)
        self.pclo_edit = QLineEdit()
        self.connect(self.pclo_cb, SIGNAL("toggled(bool)"),
                     self.pclo_edit.setEnabled)
        self.pclo_edit.setEnabled(False)
        self.pclo_edit.setToolTip(
            _("<b>-u</b> is added to the "
              "other options you set here"))
        new_layout.addWidget(self.pclo_edit, 2, 1)

        #TODO: Add option for "Post-mortem debugging"

        # Checkbox to preserve the old behavior, i.e. always open the dialog
        # on first run
        hline = QFrame()
        hline.setFrameShape(QFrame.HLine)
        hline.setFrameShadow(QFrame.Sunken)
        self.firstrun_cb = QCheckBox(ALWAYS_OPEN_FIRST_RUN % _("this dialog"))
        self.connect(self.firstrun_cb, SIGNAL("clicked(bool)"),
                     self.set_firstrun_o)
        self.firstrun_cb.setChecked(firstrun_o)

        layout = QVBoxLayout()
        layout.addWidget(interpreter_group)
        layout.addWidget(common_group)
        layout.addWidget(new_group)
        layout.addWidget(hline)
        layout.addWidget(self.firstrun_cb)
        self.setLayout(layout)
示例#53
0
    def set_widgets(self):
        """Set widgets on the Threshold tab."""
        clear_layout(self.gridLayoutThreshold)

        # Set text in the label
        layer_purpose = self.parent.step_kw_purpose.selected_purpose()
        layer_subcategory = self.parent.step_kw_subcategory.\
            selected_subcategory()
        classification = self.parent.step_kw_classification. \
            selected_classification()

        if is_raster_layer(self.parent.layer):
            statistics = self.parent.layer.dataProvider().bandStatistics(
                1, QgsRasterBandStats.All, self.parent.layer.extent(), 0)
            text = continuous_raster_question % (
                layer_purpose['name'], layer_subcategory['name'],
                classification['name'], statistics.minimumValue,
                statistics.maximumValue)
        else:
            field_name = self.parent.step_kw_field.selected_fields()
            field_index = self.parent.layer.fieldNameIndex(field_name)
            min_value_layer = self.parent.layer.minimumValue(field_index)
            max_value_layer = self.parent.layer.maximumValue(field_index)
            text = continuous_vector_question % (
                layer_purpose['name'], layer_subcategory['name'], field_name,
                classification['name'], min_value_layer, max_value_layer)
        self.lblThreshold.setText(text)

        thresholds = self.parent.get_existing_keyword('thresholds')
        selected_unit = self.parent.step_kw_unit.selected_unit()['key']

        self.classes = OrderedDict()
        classes = classification.get('classes')
        # Sort by value, put the lowest first
        classes = sorted(classes, key=lambda k: k['value'])

        for i, the_class in enumerate(classes):
            class_layout = QHBoxLayout()

            # Class label
            class_label = QLabel(the_class['name'])

            # Min label
            min_label = QLabel(tr('Min >'))

            # Min value as double spin
            min_value_input = QDoubleSpinBox()
            # TODO(IS) We can set the min and max depends on the unit, later
            min_value_input.setMinimum(0)
            min_value_input.setMaximum(999999)
            if thresholds.get(the_class['key']):
                min_value_input.setValue(thresholds[the_class['key']][0])
            else:
                default_min = the_class['numeric_default_min']
                if isinstance(default_min, dict):
                    default_min = the_class['numeric_default_min'][
                        selected_unit]
                min_value_input.setValue(default_min)
            min_value_input.setSingleStep(0.1)

            # Max label
            max_label = QLabel(tr('Max <='))

            # Max value as double spin
            max_value_input = QDoubleSpinBox()
            # TODO(IS) We can set the min and max depends on the unit, later
            max_value_input.setMinimum(0)
            max_value_input.setMaximum(999999)
            if thresholds.get(the_class['key']):
                max_value_input.setValue(thresholds[the_class['key']][1])
            else:
                default_max = the_class['numeric_default_max']
                if isinstance(default_max, dict):
                    default_max = the_class['numeric_default_max'][
                        selected_unit]
                max_value_input.setValue(default_max)
            max_value_input.setSingleStep(0.1)

            # Add to class_layout
            class_layout.addWidget(min_label)
            class_layout.addWidget(min_value_input)
            # class_layout.addStretch(1)
            class_layout.addWidget(max_label)
            class_layout.addWidget(max_value_input)

            # Add to grid_layout
            self.gridLayoutThreshold.addWidget(class_label, i, 0)
            self.gridLayoutThreshold.addLayout(class_layout, i, 1)

            self.classes[the_class['key']] = [min_value_input, max_value_input]

        self.gridLayoutThreshold.setSpacing(0)

        def min_max_changed(index, the_string):
            """Slot when min or max value change.

            :param index: The index of the double spin.
            :type index: int

            :param the_string: The flag to indicate the min or max value.
            :type the_string: str
            """
            if the_string == 'Max value':
                current_max_value = self.classes.values()[index][1]
                target_min_value = self.classes.values()[index + 1][0]
                if current_max_value.value() != target_min_value.value():
                    target_min_value.setValue(current_max_value.value())
            elif the_string == 'Min value':
                current_min_value = self.classes.values()[index][0]
                target_max_value = self.classes.values()[index - 1][1]
                if current_min_value.value() != target_max_value.value():
                    target_max_value.setValue(current_min_value.value())

        # Set behaviour
        for k, v in self.classes.items():
            index = self.classes.keys().index(k)
            if index < len(self.classes) - 1:
                # Max value changed
                v[1].valueChanged.connect(
                    partial(min_max_changed,
                            index=index,
                            the_string='Max value'))
            if index > 0:
                # Min value
                v[0].valueChanged.connect(
                    partial(min_max_changed,
                            index=index,
                            the_string='Min value'))
示例#54
0
    def setup_ui(self):
        """Load all the components of the ui during the install process."""
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)

        self.__toolbar = QToolBar()
        self.__toolbar.setObjectName('custom')
        hbox = QHBoxLayout()
        vbox.addLayout(hbox)

        self.stack = StackedWidget()
        vbox.addWidget(self.stack)

        self._console = console_widget.ConsoleWidget()
        self.stack.addWidget(self._console)

        self._runWidget = run_widget.RunWidget()
        self.stack.addWidget(self._runWidget)

        self._web = web_render.WebRender()
        self.stack.addWidget(self._web)

        self._findInFilesWidget = find_in_files.FindInFilesWidget(
            self.parent())
        self.stack.addWidget(self._findInFilesWidget)

        #Last Element in the Stacked widget
        self._results = results.Results(self)
        self.stack.addWidget(self._results)

        self._btnConsole = QPushButton(QIcon(":img/console"), '')
        self._btnConsole.setToolTip(self.tr("Console"))
        self._btnRun = QPushButton(QIcon(":img/play"), '')
        self._btnRun.setToolTip(self.tr("Output"))
        self._btnWeb = QPushButton(QIcon(":img/web"), '')
        self._btnWeb.setToolTip(self.tr("Web Preview"))
        self._btnFind = QPushButton(QIcon(":img/find"), '')
        self._btnFind.setToolTip(self.tr("Find in Files"))
        #Toolbar
        hbox.addWidget(self.__toolbar)
        self.__toolbar.addWidget(self._btnConsole)
        self.__toolbar.addWidget(self._btnRun)
        self.__toolbar.addWidget(self._btnWeb)
        self.__toolbar.addWidget(self._btnFind)
        self.__toolbar.addSeparator()
        hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding))
        btn_close = QPushButton(
            self.style().standardIcon(QStyle.SP_DialogCloseButton), '')
        btn_close.setObjectName('navigation_button')
        btn_close.setToolTip(self.tr('F4: Show/Hide'))
        hbox.addWidget(btn_close)

        # Not Configurable Shortcuts
        shortEscMisc = QShortcut(QKeySequence(Qt.Key_Escape), self)

        self.connect(shortEscMisc, SIGNAL("activated()"), self.hide)
        self.connect(self._btnConsole, SIGNAL("clicked()"),
                     lambda: self._item_changed(0))
        self.connect(self._btnRun, SIGNAL("clicked()"),
                     lambda: self._item_changed(1))
        self.connect(self._btnWeb, SIGNAL("clicked()"),
                     lambda: self._item_changed(2))
        self.connect(self._btnFind, SIGNAL("clicked()"),
                     lambda: self._item_changed(3))
        self.connect(btn_close, SIGNAL('clicked()'), self.hide)
示例#55
0
    def __init__(self, parent, search_text, search_text_regexp, search_path,
                 include, include_idx, include_regexp,
                 exclude, exclude_idx, exclude_regexp,
                 supported_encodings, in_python_path, more_options):
        QWidget.__init__(self, parent)
        
        if search_path is None:
            search_path = os.getcwdu()
        
        if not isinstance(search_text, (list, tuple)):
            search_text = [search_text]
        if not isinstance(search_path, (list, tuple)):
            search_path = [search_path]
        if not isinstance(include, (list, tuple)):
            include = [include]
        if not isinstance(exclude, (list, tuple)):
            exclude = [exclude]

        self.supported_encodings = supported_encodings

        # Layout 1
        hlayout1 = QHBoxLayout()
        self.search_text = PatternComboBox(self, search_text,
                                           _("Search pattern"))
        self.edit_regexp = create_toolbutton(self,
                                             icon=get_icon("advanced.png"),
                                             tip=_("Regular expression"))
        self.edit_regexp.setCheckable(True)
        self.edit_regexp.setChecked(search_text_regexp)
        self.more_widgets = ()
        self.more_options = create_toolbutton(self,
                                              toggled=self.toggle_more_options)
        self.more_options.setCheckable(True)
        self.more_options.setChecked(more_options)
        
        self.ok_button = create_toolbutton(self, text=_("Search"),
                                icon=get_std_icon("DialogApplyButton"),
                                triggered=lambda: self.emit(SIGNAL('find()')),
                                tip=_("Start search"),
                                text_beside_icon=True)
        self.connect(self.ok_button, SIGNAL('clicked()'), self.update_combos)
        self.stop_button = create_toolbutton(self, text=_("Stop"),
                                icon=get_icon("terminate.png"),
                                triggered=lambda: self.emit(SIGNAL('stop()')),
                                tip=_("Stop search"),
                                text_beside_icon=True)
        self.stop_button.setEnabled(False)
        for widget in [self.search_text, self.edit_regexp,
                       self.ok_button, self.stop_button, self.more_options]:
            hlayout1.addWidget(widget)

        # Layout 2
        hlayout2 = QHBoxLayout()
        self.include_pattern = PatternComboBox(self, include,
                                               _("Included filenames pattern"))
        if include_idx is not None and include_idx >= 0 \
           and include_idx < self.include_pattern.count():
            self.include_pattern.setCurrentIndex(include_idx)
        self.include_regexp = create_toolbutton(self,
                                            icon=get_icon("advanced.png"),
                                            tip=_("Regular expression"))
        self.include_regexp.setCheckable(True)
        self.include_regexp.setChecked(include_regexp)
        include_label = QLabel(_("Include:"))
        include_label.setBuddy(self.include_pattern)
        self.exclude_pattern = PatternComboBox(self, exclude,
                                               _("Excluded filenames pattern"))
        if exclude_idx is not None and exclude_idx >= 0 \
           and exclude_idx < self.exclude_pattern.count():
            self.exclude_pattern.setCurrentIndex(exclude_idx)
        self.exclude_regexp = create_toolbutton(self,
                                            icon=get_icon("advanced.png"),
                                            tip=_("Regular expression"))
        self.exclude_regexp.setCheckable(True)
        self.exclude_regexp.setChecked(exclude_regexp)
        exclude_label = QLabel(_("Exclude:"))
        exclude_label.setBuddy(self.exclude_pattern)
        for widget in [include_label, self.include_pattern,
                       self.include_regexp,
                       exclude_label, self.exclude_pattern,
                       self.exclude_regexp]:
            hlayout2.addWidget(widget)

        # Layout 3
        hlayout3 = QHBoxLayout()
        self.python_path = QRadioButton(_("PYTHONPATH"), self)
        self.python_path.setChecked(in_python_path)
        self.python_path.setToolTip(_(
                          "Search in all directories listed in sys.path which"
                          " are outside the Python installation directory"))        
        self.hg_manifest = QRadioButton(_("Hg repository"), self)
        self.detect_hg_repository()
        self.hg_manifest.setToolTip(
                                _("Search in current directory hg repository"))
        self.custom_dir = QRadioButton(_("Here:"), self)
        self.custom_dir.setChecked(not in_python_path)
        self.dir_combo = PathComboBox(self)
        self.dir_combo.addItems(search_path)
        self.dir_combo.setToolTip(_("Search recursively in this directory"))
        self.connect(self.dir_combo, SIGNAL("open_dir(QString)"),
                     self.set_directory)
        self.connect(self.python_path, SIGNAL('toggled(bool)'),
                     self.dir_combo.setDisabled)
        self.connect(self.hg_manifest, SIGNAL('toggled(bool)'),
                     self.dir_combo.setDisabled)
        browse = create_toolbutton(self, icon=get_std_icon('DirOpenIcon'),
                                   tip=_('Browse a search directory'),
                                   triggered=self.select_directory)
        for widget in [self.python_path, self.hg_manifest, self.custom_dir,
                       self.dir_combo, browse]:
            hlayout3.addWidget(widget)
            
        self.connect(self.search_text, SIGNAL("valid(bool)"),
                     lambda valid: self.emit(SIGNAL('find()')))
        self.connect(self.include_pattern, SIGNAL("valid(bool)"),
                     lambda valid: self.emit(SIGNAL('find()')))
        self.connect(self.exclude_pattern, SIGNAL("valid(bool)"),
                     lambda valid: self.emit(SIGNAL('find()')))
        self.connect(self.dir_combo, SIGNAL("valid(bool)"),
                     lambda valid: self.emit(SIGNAL('find()')))
            
        vlayout = QVBoxLayout()
        vlayout.setContentsMargins(0, 0, 0, 0)
        vlayout.addLayout(hlayout1)
        vlayout.addLayout(hlayout2)
        vlayout.addLayout(hlayout3)
        self.more_widgets = (hlayout2, hlayout3)
        self.toggle_more_options(more_options)
        self.setLayout(vlayout)
                
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
示例#56
0
class TestLayerWidget( ut.TestCase ):
    """
    Create two layers and add them to a LayerWidget.
    Then change one of the layer visibilities and verify that the layer widget appearance updates.
    
    At the time of this writing, the widget doesn't properly repaint the selected layer (all others repaint correctly).
    """
    
    @classmethod
    def setUpClass(cls):
        if 'TRAVIS' in os.environ:
            # This test fails on Travis-CI for unknown reasons,
            #  probably due to the variability of time.sleep().
            # Skip it on Travis-CI.
            import nose
            raise nose.SkipTest

        cls.app = QApplication([])
        cls.errors = False

    @classmethod
    def tearDownClass(cls):
        del cls.app
    
    def impl(self):
        try:
            # Capture the window before we change anything
            beforeImg = QPixmap.grabWindow( self.w.winId() ).toImage()
            
            # Change the visibility of the *selected* layer
            self.o2.visible = False
            
            self.w.repaint()
            
            # Make sure the GUI is caught up on paint events
            QApplication.processEvents()
            
            # We must sleep for the screenshot to be right.
            time.sleep(0.1) 

            # Capture the window now that we've changed a layer.
            afterImg = QPixmap.grabWindow( self.w.winId() ).toImage()
    
            # Optional: Save the files so we can inspect them ourselves...
            #beforeImg.save('before.png')
            #afterImg.save('after.png')

            # Before and after should NOT match.
            assert beforeImg != afterImg
        except:
            # Catch all exceptions and print them
            # We must finish so we can quit the app.
            import traceback
            traceback.print_exc()
            TestLayerWidget.errors = True

        qApp.quit()

    def test_repaint_after_visible_change(self):
        self.model = LayerStackModel()

        self.o1 = Layer([])
        self.o1.name = "Fancy Layer"
        self.o1.opacity = 0.5
        self.model.append(self.o1)
        
        self.o2 = Layer([])
        self.o2.name = "Some other Layer"
        self.o2.opacity = 0.25
        self.model.append(self.o2)
        
        self.view = LayerWidget(None, self.model)
        self.view.show()
        self.view.updateGeometry()
    
        self.w = QWidget()
        self.lh = QHBoxLayout(self.w)
        self.lh.addWidget(self.view)
        self.w.setGeometry(100, 100, 300, 300)
        self.w.show()

        # Run the test within the GUI event loop
        QTimer.singleShot(500, self.impl )
        self.app.exec_()
        
        # Were there errors?
        assert not TestLayerWidget.errors, "There were GUI errors/failures.  See above."        
示例#57
0
        self.expandItem(me)


editframecontent = None
if __name__ == "__main__":

    ev = IPETEvaluation.fromXMLFile("test/testevaluate.xml")

    app = QApplication(sys.argv)
    mainwindow = QMainWindow()
    thewidget = QWidget(mainwindow)
    treeview = IpetTreeView(thewidget)

    layout = QHBoxLayout()
    layout.addWidget(treeview)

    editframe = QFrame(thewidget)
    layout.addWidget(editframe)

    layout2 = QGridLayout()

    editframe.setLayout(layout2)

    thewidget.setLayout(layout)
    mainwindow.setCentralWidget(thewidget)
    treeview.populateTree(ev)

    def redrawEditFrameContent():
        item = treeview.selectedItems()[0]
示例#58
0
    def __init__(self):
        QWizardPage.__init__(self)
        self.setTitle(self.tr("New Project Data"))
        self.setSubTitle(
            self.tr(
                "Complete the following fields to create the Project Structure"
            ))

        gbox = QGridLayout(self)
        #Names of the fields to complete
        self.lblName = QLabel(self.tr("New Project Name (*):"))
        self.lblPlace = QLabel(self.tr("Create in (*):"))
        self.lblDescription = QLabel(self.tr("Project Description:"))
        self.lblLicense = QLabel(self.tr("Project License:"))
        self.lblVenvFolder = QLabel(self.tr("Virtualenv Folder:"))
        gbox.addWidget(self.lblName, 0, 0, Qt.AlignRight)
        gbox.addWidget(self.lblPlace, 1, 0, Qt.AlignRight)
        gbox.addWidget(self.lblDescription, 2, 0, Qt.AlignTop)
        gbox.addWidget(self.lblLicense, 3, 0, Qt.AlignRight)
        gbox.addWidget(self.lblVenvFolder, 4, 0, Qt.AlignRight)

        #Fields on de right of the grid
        #Name
        self.txtName = QLineEdit()
        #Location
        hPlace = QHBoxLayout()
        self.txtPlace = QLineEdit()
        self.txtPlace.setReadOnly(True)
        self.btnExamine = QPushButton(self.tr("Browse..."))
        hPlace.addWidget(self.txtPlace)
        hPlace.addWidget(self.btnExamine)
        #Virtualenv
        vPlace = QHBoxLayout()
        self.vtxtPlace = QLineEdit()
        self._dir_completer = QCompleter()
        self._dir_completer.setModel(QDirModel(self._dir_completer))
        self.vtxtPlace.setCompleter(self._dir_completer)
        self.vbtnExamine = QPushButton(self.tr("Browse..."))
        vPlace.addWidget(self.vtxtPlace)
        vPlace.addWidget(self.vbtnExamine)
        #Project Description
        self.txtDescription = QPlainTextEdit()
        #Project License
        self.cboLicense = QComboBox()
        self.cboLicense.setFixedWidth(250)
        self.cboLicense.addItem('Apache License 2.0')
        self.cboLicense.addItem('Artistic License/GPL')
        self.cboLicense.addItem('Eclipse Public License 1.0')
        self.cboLicense.addItem('GNU General Public License v2')
        self.cboLicense.addItem('GNU General Public License v3')
        self.cboLicense.addItem('GNU Lesser General Public License')
        self.cboLicense.addItem('MIT License')
        self.cboLicense.addItem('Mozilla Public License 1.1')
        self.cboLicense.addItem('Mozilla Public License 2.0')
        self.cboLicense.addItem('New BSD License')
        self.cboLicense.addItem('Other Open Source')
        self.cboLicense.addItem('Other')
        self.cboLicense.setCurrentIndex(4)
        #Add to Grid
        gbox.addWidget(self.txtName, 0, 1)
        gbox.addLayout(hPlace, 1, 1)
        gbox.addWidget(self.txtDescription, 2, 1)
        gbox.addWidget(self.cboLicense, 3, 1)
        gbox.addLayout(vPlace, 4, 1)
        #Signal
        self.connect(self.btnExamine, SIGNAL('clicked()'), self.load_folder)
        self.connect(self.vbtnExamine, SIGNAL('clicked()'),
                     self.load_folder_venv)
        self.connect(self.txtName, SIGNAL('textChanged(const QString&)'),
                     lambda: self.emit(SIGNAL("completeChanged()")))
示例#59
0
    def create_layout(self):
        ok_cancel_box = QHBoxLayout()
        ok_cancel_box.addWidget(self.cancel_button)

        grid = QGridLayout()

        irow = 0
        grid.addWidget(self.name, irow, 0)
        grid.addWidget(self.name_edit, irow, 1)
        irow += 1

        grid.addWidget(self.color, irow, 0)
        grid.addWidget(self.color_edit, irow, 1)
        irow += 1

        grid.addWidget(self.opacity, irow, 0)
        if self.use_slider:
            grid.addWidget(self.opacity_edit, irow, 2)
            grid.addWidget(self.opacity_slider_edit, irow, 1)
        else:
            grid.addWidget(self.opacity_edit, irow, 1)
        irow += 1

        grid.addWidget(self.line_width, irow, 0)
        if self.use_slider:
            grid.addWidget(self.line_width_edit, irow, 2)
            grid.addWidget(self.line_width_slider_edit, irow, 1)
        else:
            grid.addWidget(self.line_width_edit, irow, 1)
        irow += 1

        grid.addWidget(self.point_size, irow, 0)
        if self.use_slider:
            grid.addWidget(self.point_size_edit, irow, 2)
            grid.addWidget(self.point_size_slider_edit, irow, 1)
        else:
            grid.addWidget(self.point_size_edit, irow, 1)
        irow += 1

        grid.addWidget(self.bar_scale, irow, 0)
        if self.use_slider and 0:
            grid.addWidget(self.bar_scale_edit, irow, 2)
            grid.addWidget(self.bar_scale_slider_edit, irow, 1)
        else:
            grid.addWidget(self.bar_scale_edit, irow, 1)
        irow += 1

        checkboxs = QButtonGroup(self)
        checkboxs.addButton(self.checkbox_show)
        checkboxs.addButton(self.checkbox_hide)

        vbox = QVBoxLayout()
        vbox.addWidget(self.table)
        vbox.addLayout(grid)

        if 0:
            vbox.addWidget(self.checkbox_show)
            vbox.addWidget(self.checkbox_hide)
        else:
            vbox1 = QVBoxLayout()
            vbox1.addWidget(self.checkbox_show)
            vbox1.addWidget(self.checkbox_hide)
            vbox.addLayout(vbox1)

        vbox.addStretch()
        #vbox.addWidget(self.check_apply)
        vbox.addLayout(ok_cancel_box)
        self.setLayout(vbox)
示例#60
0
 def initUI(self):
     layout = QHBoxLayout(self)
     self.control_widget = Well_Log_View_Control(self)
     self.matplotlib_widget = MatplotlibWidget(self)
     layout.addWidget(self.control_widget)
     layout.addWidget(self.matplotlib_widget)