Exemple #1
0
   def paint_mainWindow(self):
         
      # Define and use a "Grid Layout" for the main window.
      grid = QGridLayout()
      grid.addWidget(self.textArea, 1, 1)
      grid.addWidget(self.tabs,     2, 1)
      
      # Create central widget, add layout, and set
      central_widget = QWidget()
      central_widget.setLayout(grid)
      self.setCentralWidget(central_widget)      
      
      # Fun feature for users. If you are going to have a toolbar then you 
      # really need this status bar to show what the icons do.        
      self.statusbar = QStatusBar(self) 
      self.statusbar.setObjectName( "statusbar") 
      MainWindow.setStatusBar(self, self.statusbar) 
      self.statusbar.show()
      
      # Initial settings for the main window 
      #
      #    Set the Main Window Geometry
      top    =  100 # Main Window initial 'top' position (as pixels from top of screen)
      left   =  100 # Main Window initial 'left' position (as pixels from left side of screen)
      width  = 1000 # Main Window initial 'width' (as pixels)
      height =  700 # Main Window initial 'height' (as pixels)
      self.setGeometry(QRect(top, left, width, height))  
 
      # Create connection(s)
      #    If the contents of the text area are changed then call a function 
      #    to set the appropriate file menu state. This file menu state can 
      #    also be used to ensure clean exits. In english, keep track 
      #    of changes to the text editor. It affects the "state" of the
      #    application. See setState()
      self.connect(self.textArea, SIGNAL("textChanged()"), self.textChanged)
Exemple #2
0
	def __init__(self, parent=None):
		super(TestDlg, self).__init__(parent)
		self.mymodel = None
		self.myscene = DragEnabledScene(QRectF(-400,-300,800,600))
		self.myview = QGraphicsView()
		self.myview.setScene(self.myscene)
		self.myfile = None
		layout = QVBoxLayout()
		layout.addWidget(self.myview)
		buttonLayout = QHBoxLayout()
		self.savebutton = QPushButton('Save')
		self.loadbutton = QPushButton('Load')
		self.renderbutton = QPushButton('Accept')
		buttonLayout.addWidget(self.savebutton)
		buttonLayout.addWidget(self.loadbutton)
		buttonLayout.addWidget(self.renderbutton)
		layout.addLayout(buttonLayout)
		self.statusbar =  QStatusBar()
		layout.addWidget(self.statusbar)
		self.statusbar.showMessage("Ready.",2000)
		self.setLayout(layout)

		self.loadfromInitData()

		self.savebutton.pressed.connect(self.saveMatrix)
		self.loadbutton.pressed.connect(self.loadMatrix)
		self.myscene.selectionChanged.connect(self.updateStatus)
		self.myscene.modelchanged.connect(self.changeModel)

		self.renderbutton.pressed.connect(self.testDistance)
Exemple #3
0
    def __init__(self):
        QStatusBar.__init__(self)
        self.hide()
        Edis.load_component("status_bar", self)

        # Conexiones
        self.messageChanged.connect(self._clean_status)
Exemple #4
0
    def __init__(self, parent=None):
        QStatusBar.__init__(self, parent)

        self._widgetStatus = QWidget()
        vbox = QVBoxLayout(self._widgetStatus)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        # Search Layout
        self._searchWidget = SearchWidget(self)
        vbox.addWidget(self._searchWidget)
        # Replace Layout
        self._replaceWidget = ReplaceWidget(self)
        vbox.addWidget(self._replaceWidget)
        self._replaceWidget.setVisible(False)
        # Code Locator
        self._codeLocator = locator.CodeLocatorWidget(self)
        vbox.addWidget(self._codeLocator)
        self._codeLocator.setVisible(False)
        # File system completer
        self._fileSystemOpener = FileSystemOpener()
        vbox.addWidget(self._fileSystemOpener)
        self._fileSystemOpener.setVisible(False)

        self.addWidget(self._widgetStatus)

        self.connect(self, SIGNAL("messageChanged(QString)"), self.message_end)
        self.connect(
            self._replaceWidget._btnCloseReplace, SIGNAL("clicked()"), lambda: self._replaceWidget.setVisible(False)
        )
        self.connect(self._replaceWidget._btnReplace, SIGNAL("clicked()"), self.replace)
        self.connect(self._replaceWidget._btnReplaceAll, SIGNAL("clicked()"), self.replace_all)
        self.connect(self._replaceWidget._btnReplaceSelection, SIGNAL("clicked()"), self.replace_selected)
        self.connect(self._fileSystemOpener.btnClose, SIGNAL("clicked()"), self.hide_status)
        self.connect(self._fileSystemOpener, SIGNAL("requestHide()"), self.hide_status)
Exemple #5
0
    def __init__(self):
        super().__init__()

        self.__central_widget = CentralWidget(None)

        self.__board = self.__central_widget.board
        self.__nodes_view = self.__central_widget.nodes_widget

        self.__status_bar = QStatusBar()

        self.setCentralWidget(self.__central_widget)
        self.setStatusBar(self.__status_bar)
        self.setMinimumSize(self.__central_widget.size())

        self.__board.on_click.connect(self.on_piece_click)
        self.__nodes_view.node_click.connect(self.on_point_click)

        self.__central_widget.button_bar.open_click.connect(self.on_open_click)
        self.__central_widget.button_bar.save_click.connect(self.on_save_click)
        self.__central_widget.button_bar.pass_click.connect(self.on_pass_click)
        self.__central_widget.button_bar.resign_click.connect(
            self.on_resign_click)
        self.__central_widget.button_bar.count_click.connect(
            self.on_count_click)

        self.__status_bar.showMessage("Juego cargado.")
Exemple #6
0
class Ui_SLim(object):
    def setupUi(self, SLim):
        SLim.setObjectName(_fromUtf8("SLim"))
        SLim.resize(800, 601)
        self.centralwidget = QWidget(SLim)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.verticalLayout = QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        SLim.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(SLim)
        self.menubar.setGeometry(QRect(0, 0, 800, 20))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        SLim.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(SLim)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        SLim.setStatusBar(self.statusbar)

        ui_settings = slimUISettings()

        QMetaObject.connectSlotsByName(SLim)

        self.loopers = []
        self.loopers.append(LooperWidget(self.centralwidget, 0, ui_settings.looper))
        self.loopers.append(LooperWidget(self.centralwidget, 1, ui_settings.looper))
        for looper in self.loopers:
            self.verticalLayout.addWidget(looper)

        self.retranslateUi(SLim)

    def retranslateUi(self, SLim):
        for looper in SLim.ui.loopers:
            looper.retranslateUi()
        SLim.setWindowTitle(QApplication.translate("SLim", "MainWindow", None, QApplication.UnicodeUTF8))
Exemple #7
0
    def __init__(self):
        QStatusBar.__init__(self)
        self.hide()
        Edis.load_component("status_bar", self)

        # Conexiones
        self.messageChanged.connect(self._clean_status)
Exemple #8
0
    def __init__(self):
        QStatusBar.__init__(self)
        self.editor = None

        self.widgetStatus = QWidget()
        vbox = QVBoxLayout(self.widgetStatus)
        vbox.setContentsMargins(0, 0, 0, 0)
        #Search Layout
        hSearch = QHBoxLayout()
        self.line = TextLine(self)
        self.line.setMinimumWidth(250)
        self.checkBackward = QCheckBox('Find Backward')
        self.checkSensitive = QCheckBox('Respect Case Sensitive')
        self.checkWholeWord = QCheckBox('Find Whole Words')
        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.btnNext = QPushButton(
            self.style().standardIcon(QStyle.SP_ArrowRight), '')
        hSearch.addWidget(self.btnClose)
        hSearch.addWidget(self.line)
        hSearch.addWidget(self.btnFind)
        hSearch.addWidget(self.btnPrevious)
        hSearch.addWidget(self.btnNext)
        hSearch.addWidget(self.checkBackward)
        hSearch.addWidget(self.checkSensitive)
        hSearch.addWidget(self.checkWholeWord)
        vbox.addLayout(hSearch)
        #Replace Layout
        hReplace = QHBoxLayout()
        self.lineReplace = TextLine(self)
        self.lineReplace.setMinimumWidth(250)
        self.btnCloseReplace = QPushButton(
            self.style().standardIcon(QStyle.SP_DialogCloseButton), '')
        self.btnReplace = QPushButton('Replace')
        self.btnReplaceAll = QPushButton('Replace All')
        hReplace.addWidget(self.btnCloseReplace)
        hReplace.addWidget(self.lineReplace)
        hReplace.addWidget(self.btnReplace)
        hReplace.addWidget(self.btnReplaceAll)
        vbox.addLayout(hReplace)
        self.replace_visibility(False)

        self.addWidget(self.widgetStatus)

        self.shortEsc = QShortcut(QKeySequence(Qt.Key_Escape), self)

        self.connect(self.btnClose, SIGNAL("clicked()"), self.hide_status)
        self.connect(self.btnFind, SIGNAL("clicked()"), self.find)
        self.connect(self.btnNext, SIGNAL("clicked()"), self.find_next)
        self.connect(self.btnPrevious, SIGNAL("clicked()"), self.find_previous)
        self.connect(self, SIGNAL("messageChanged(QString)"), self.message_end)
        self.connect(self.btnCloseReplace, SIGNAL("clicked()"),
                     lambda: self.replace_visibility(False))
        self.connect(self.btnReplace, SIGNAL("clicked()"), self.replace)
        self.connect(self.btnReplaceAll, SIGNAL("clicked()"), self.replace_all)
        self.connect(self.shortEsc, SIGNAL("activated()"), self.hide_status)
Exemple #9
0
	def __init__(self, parent = None):
		QStatusBar.__init__(self, parent)
		self.prnt = parent

		self.clearMessage()
		self.reformat()
		self.status = QLabel()
		self.addPermanentWidget(self.status)
Exemple #10
0
    def __init__(self, parent):

        QStatusBar.__init__(self, parent)

        self.setWindowOpacity(1.50)
        self.compt = 0
        self.timerEvent(self.compt)
        self.startTimer(5000)
Exemple #11
0
 def message_end(self, message):
     if message == '':
         self.hide()
         QStatusBar.clearMessage(self)
         self._widgetStatus.show()
         widget = main_container.MainContainer().get_actual_widget()
         if widget:
             widget.setFocus()
Exemple #12
0
    def __init__(self, parent):

        QStatusBar.__init__(self, parent)

        self.setWindowOpacity(1.50)
        self.compt = 0
        self.timerEvent(self.compt)
        self.startTimer(5000)
Exemple #13
0
 def message_end(self, message):
     if message == '':
         self.hide()
         QStatusBar.clearMessage(self)
         self._widgetStatus.show()
         widget = main_container.MainContainer().get_actual_widget()
         if widget:
             widget.setFocus()
Exemple #14
0
    def __init__(self, showEmptyDatasetNodes=False, parent=None):
        """Constructor."""

        super(Visor, self).__init__(parent)
        self.setupUi(self)

        self.controller = VisorController.VisorController()
        self.controller.threddsServerMapObjectRetrieved.connect(
            self.onNewDatasetsAvailable)
        self.controller.threddsDataSetUpdated.connect(self.onDataSetUpdated)
        self.controller.mapImageRetrieved.connect(self.showNewImage)
        self.controller.standardMessage.connect(
            self.postInformationMessageToUser)
        self.controller.errorMessage.connect(self.postCriticalErrorToUser)
        self.controller.mapInfoRetrieved.connect(
            self._onMapInfoReceivedFromController)
        self.controller.batchDownloadFinished.connect(self.createLayerGroup)

        self.showEmptyDatasetNodes = showEmptyDatasetNodes  # TODO: self-explanatory...
        self.combo_dataset_list.currentIndexChanged.connect(
            self._onDataSetItemChanged)
        self.tree_widget.itemClicked.connect(self._onMapTreeWidgetItemClicked)
        self.tree_widget.itemExpanded.connect(
            self._onMapTreeWidgetItemExpanded)

        self.tabWidget.currentChanged.connect(self.runWhenTabChange)

        self.connect(self.combo_wcs_coverage,
                     SIGNAL("currentIndexChanged(const QString&)"),
                     self._onCoverageSelectorItemChanged)
        self.connect(self.combo_wms_layer,
                     SIGNAL("currentIndexChanged(const QString&)"),
                     self._onWMSLayerSelectorItemChanged)
        self.connect(self.combo_wms_style_type,
                     SIGNAL("currentIndexChanged(const QString&)"),
                     self._onWMSStyleTypeSelectorItemChanged)
        self.connect(self.combo_wms_time, SIGNAL("currentIndexChanged(int)"),
                     self._onWMSFirstTimeChanged)
        self.connect(self.combo_wcs_time, SIGNAL("currentIndexChanged(int)"),
                     self._onWCSFirstTimeChanged)

        self.button_req_map.clicked.connect(self._onbuttonReqMapClicked)
        #self.actionToggleAlwaysOnTop.toggled.connect(self._onAlwaysOnTopPrefsChanged)
        self.buttonManageServers.clicked.connect(
            self._onManageServersRequested)
        self.button_req_animation.clicked.connect(self.toggleAnimationMenu)

        # We add a status bar to this QDockWidget:
        self.statusbar = QStatusBar()
        self.gridLayout.addWidget(self.statusbar)

        self.datasetInUse = None
        self.uiAnimation = None
        self.currentMap = None
        self.wcsAvailableTimes = []
        self.wmsAvailableTimes = []

        self.firstRunThisSession = True
Exemple #15
0
 def show(self):
     self.clearMessage()
     QStatusBar.show(self)
     editor = main_container.MainContainer().get_actual_editor()
     if editor and editor.textCursor().hasSelection():
         text = editor.textCursor().selectedText()
         self._searchWidget._line.setText(text)
     if self._widgetStatus.isVisible():
         self._searchWidget._line.setFocus()
         self._searchWidget._line.selectAll()
Exemple #16
0
 def show(self):
     self.clearMessage()
     QStatusBar.show(self)
     editor = main_container.MainContainer().get_actual_editor()
     if editor and editor.textCursor().hasSelection():
         text = editor.textCursor().selectedText()
         self._searchWidget._line.setText(text)
     if self._widgetStatus.isVisible():
         self._searchWidget._line.setFocus()
         self._searchWidget._line.selectAll()
Exemple #17
0
    def __init__(self):
        QStatusBar.__init__(self)
        self.editor = None

        self.widgetStatus = QWidget()
        vbox = QVBoxLayout(self.widgetStatus)
        vbox.setContentsMargins(0, 0, 0, 0)
        #Search Layout
        hSearch = QHBoxLayout()
        self.line = TextLine(self)
        self.line.setMinimumWidth(250)
        self.checkBackward = QCheckBox('Find Backward')
        self.checkSensitive = QCheckBox('Respect Case Sensitive')
        self.checkWholeWord = QCheckBox('Find Whole Words')
        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.btnNext = QPushButton(self.style().standardIcon(QStyle.SP_ArrowRight), '')
        hSearch.addWidget(self.btnClose)
        hSearch.addWidget(self.line)
        hSearch.addWidget(self.btnFind)
        hSearch.addWidget(self.btnPrevious)
        hSearch.addWidget(self.btnNext)
        hSearch.addWidget(self.checkBackward)
        hSearch.addWidget(self.checkSensitive)
        hSearch.addWidget(self.checkWholeWord)
        vbox.addLayout(hSearch)
        #Replace Layout
        hReplace = QHBoxLayout()
        self.lineReplace = TextLine(self)
        self.lineReplace.setMinimumWidth(250)
        self.btnCloseReplace = QPushButton(self.style().standardIcon(QStyle.SP_DialogCloseButton), '')
        self.btnReplace = QPushButton('Replace')
        self.btnReplaceAll = QPushButton('Replace All')
        hReplace.addWidget(self.btnCloseReplace)
        hReplace.addWidget(self.lineReplace)
        hReplace.addWidget(self.btnReplace)
        hReplace.addWidget(self.btnReplaceAll)
        vbox.addLayout(hReplace)
        self.replace_visibility(False)

        self.addWidget(self.widgetStatus)

        self.shortEsc = QShortcut(QKeySequence(Qt.Key_Escape), self)

        self.connect(self.btnClose, SIGNAL("clicked()"), self.hide_status)
        self.connect(self.btnFind, SIGNAL("clicked()"), self.find)
        self.connect(self.btnNext, SIGNAL("clicked()"), self.find_next)
        self.connect(self.btnPrevious, SIGNAL("clicked()"), self.find_previous)
        self.connect(self, SIGNAL("messageChanged(QString)"), self.message_end)
        self.connect(self.btnCloseReplace, SIGNAL("clicked()"), lambda: self.replace_visibility(False))
        self.connect(self.btnReplace, SIGNAL("clicked()"), self.replace)
        self.connect(self.btnReplaceAll, SIGNAL("clicked()"), self.replace_all)
        self.connect(self.shortEsc, SIGNAL("activated()"), self.hide_status)
Exemple #18
0
    def __init__(self, config):
        # Initialize the object as a QWidget and
        # set its title and minimum width

        QWidget.__init__(self)

        self.config = config
        self.peerList = config.peerList
        self.setWindowTitle('BlastShare')
        self.setMinimumSize(320, 480)
        self.setMaximumWidth(320)
        self.prefw = None
        
        # connects the signals!
        self.connect(self.peerList,
                     SIGNAL("initTransfer"), self.sendFileToPeer)

        ''' Will add feature in future version '''
        '''
        shareFilesAction = QAction(QIcon('exit.png'), '&Share File(s)', self)
        shareFilesAction.setShortcut('Ctrl+O')
        shareFilesAction.setStatusTip('Share File(s)')
        shareFilesAction.triggered.connect(quitApp)
        '''
        
        preferencesAction = QAction(QIcon('exit.png'), '&Preferences', self)
        preferencesAction.setShortcut('Ctrl+P')
        preferencesAction.setStatusTip('Preferences')
        preferencesAction.triggered.connect(self.editPreferences)

        exitAction = QAction(QIcon('exit.png'), '&Exit', self)
        exitAction.setShortcut('Ctrl+Q')
        exitAction.setStatusTip('Exit application')
        exitAction.triggered.connect(quitApp)

        menubar = QMenuBar()
        fileMenu = menubar.addMenu('&File')
        
        ''' Will enable in future versions '''
        # fileMenu.addAction(shareFilesAction)
        
        fileMenu.addAction(preferencesAction)
        fileMenu.addAction(exitAction)

        layout = QVBoxLayout()
        layout.setContentsMargins(QMargins(0, 0, 0, 0))
        self.setLayout(layout)
        
        statusBar = QStatusBar()
        statusBar.showMessage('Ready')
        
        layout.addWidget(menubar)
        layout.addWidget(self.peerList)
        layout.addWidget(statusBar)
Exemple #19
0
    def __init__(self, parent):

        QStatusBar.__init__(self, parent)

        if not Config.SERV:
            print("Not Serveur ")
            return

        self.rsp = {}
        self.check = TaskThreadServer(self)
        QObject.connect(self.check, SIGNAL("download_"), self.download_)
        self.check.start()
Exemple #20
0
 def __init__(self, *args):
     QStatusBar.__init__(self, *args)
     self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
     self.setSizeGripEnabled(False)
     self.setStyleSheet("QStatusBar {border: 0} QStatusBar::item {border: 0}")
     self._label = QLabel(self)
     self._label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
     self._label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
     self._label.setStyleSheet("color: red")
     self.addWidget(self._label)
     self._timer = QTimer()
     self._timer.setSingleShot(True)
     self._timer.timeout.connect(self.clearMessage)
Exemple #21
0
 def __init__(self, *args):
     QStatusBar.__init__(self, *args)
     self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
     self.setSizeGripEnabled(False)
     self.setStyleSheet(
         "QStatusBar {border: 0} QStatusBar::item {border: 0}")
     self._label = QLabel(self)
     self._label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
     self._label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
     self._label.setStyleSheet("color: red")
     self.addWidget(self._label)
     self._timer = QTimer()
     self._timer.setSingleShot(True)
     self._timer.timeout.connect(self.clearMessage)
Exemple #22
0
    def __init__(self, parent, configuration):
        QWidget.__init__(self, parent)
        self._configuration = configuration

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        main_widget = QWidget(self)
        self._layout_main = QVBoxLayout()
        self._layout_main.setContentsMargins(0, 0, 0, 0)
        self._layout_main.setSpacing(6)
        main_widget.setLayout(self._layout_main)
        layout.addWidget(main_widget)
        self._status_bar = QStatusBar()
        layout.addWidget(self._status_bar)
        self.setLayout(layout)
Exemple #23
0
    def __init__(self, scene, *args, **kwargs):

        super(TestWindow, self).__init__(*args, **kwargs)
        # self.windowTitleChanged.connect(self.onWindowTitleChange)
        self.setWindowTitle("timeline unit test")

        # toolbar = QToolBar("och")
        # toolbar.setIconSize(QSize(20,20))
        # self.addToolBar(toolbar)

        # button_action = QAction(QIcon("balance.png"), "ochtuse", self)
        # button_action.setStatusTip("och, just do something")
        # button_action.triggered.connect(self.onMyToolBarButtonClick)
        # button_action.setCheckable(True)
        # # button_action.setShortcut(QKeySequence("Ctrl+p"))
        # # button_action.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_P))
        # button_action.setShortcut(QKeySequence.Print)
        # toolbar.addAction(button_action)
        # toolbar.addWidget(QLabel("OCH"))
        # toolbar.addWidget(QCheckBox())

        self.setStatusBar(QStatusBar(self))

        menu = self.menuBar()

        file_menu = menu.addMenu("&File")
        # file_menu.addAction(button_action)
        # file_menu.addSeparator()
        file_menu.addMenu("Do not push")
        #        file_menu.addAction()

        self._scene = scene
        gfx = self._gfx = QFramesInTracksView(self)
        # label = QLabel("och!")
        # label.setAlignment(Qt.AlignCenter)

        # ref https://doc.qt.io/archives/qq/qq26-openglcanvas.html
        self.setCentralWidget(gfx)

        scene.setSceneRect(QRectF(0, 0, 800, 600))
        gfx.setScene(scene)

        # populate fills the scene with interesting stuff.
        # self.populate()

        # Make it bigger
        # self.setWindowState(Qt.WindowMaximized)

        # Well... it's going to have an animation, ok?

        # So, I set a timer to 1 second
        # self.animator=QTimer()

        # And when it triggers, it calls the animate method
        # self.animator.timeout.connect(self.animate)

        # And I animate it once manually.
        # self.animate()
        self.show()
        self.raise_()
Exemple #24
0
    def setupUi(self, SLim):
        SLim.setObjectName(_fromUtf8("SLim"))
        SLim.resize(800, 601)
        self.centralwidget = QWidget(SLim)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.verticalLayout = QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        SLim.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(SLim)
        self.menubar.setGeometry(QRect(0, 0, 800, 20))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        SLim.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(SLim)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        SLim.setStatusBar(self.statusbar)

        ui_settings = slimUISettings()

        QMetaObject.connectSlotsByName(SLim)

        self.loopers = []
        self.loopers.append(LooperWidget(self.centralwidget, 0, ui_settings.looper))
        self.loopers.append(LooperWidget(self.centralwidget, 1, ui_settings.looper))
        for looper in self.loopers:
            self.verticalLayout.addWidget(looper)

        self.retranslateUi(SLim)
Exemple #25
0
        def setupUi(self, MainWindow):
            """
            """

            MainWindow.resize(100,200)

            # Create the "Central Widget" and add a "Layout"
            self.centralwidget = QWidget(MainWindow)
            MainWindow.setCentralWidget(self.centralwidget)
            self.verticalLayout= QVBoxLayout(self.centralwidget)

            # Add a Temperature sensor and Label Widgets
            self.t1 = QFellesThermocouple(self.centralwidget)
            self.label = QLabel(self.centralwidget)
            self.label.setText("[C]")

            # Add Widgets to Layout
            self.verticalLayout.addWidget(self.t1)
            self.verticalLayout.addWidget(self.label)

            # Add connections
            self.t1.measurement_updated.connect(self.label.setText)

            # Create the Menu bar
            self.menubar = QMenuBar(MainWindow)
            MainWindow.setMenuBar(self.menubar)
            # Create the Status Bar
            self.statusbar = QStatusBar(MainWindow)
            MainWindow.setStatusBar(self.statusbar)

            self.retranslateUi(MainWindow)
Exemple #26
0
    def __init__(self, parent=None):
        QStatusBar.__init__(self, parent)

        self._widgetStatus = QWidget()
        vbox = QVBoxLayout(self._widgetStatus)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        #Search Layout
        self._searchWidget = SearchWidget(self)
        vbox.addWidget(self._searchWidget)
        #Replace Layout
        self._replaceWidget = ReplaceWidget(self)
        vbox.addWidget(self._replaceWidget)
        self._replaceWidget.setVisible(False)
        #Code Locator
        self._codeLocator = locator.CodeLocatorWidget(self)
        vbox.addWidget(self._codeLocator)
        self._codeLocator.setVisible(False)
        #File system completer
        self._fileSystemOpener = FileSystemOpener()
        vbox.addWidget(self._fileSystemOpener)
        self._fileSystemOpener.setVisible(False)

        self.addWidget(self._widgetStatus)

        self._shortEsc = QShortcut(QKeySequence(Qt.Key_Escape), self)

        self.connect(self._searchWidget._btnClose, SIGNAL("clicked()"),
            self.hide_status)
        self.connect(self._searchWidget._btnFind, SIGNAL("clicked()"),
            self.find)
        self.connect(self._searchWidget.btnNext, SIGNAL("clicked()"),
            self.find_next)
        self.connect(self._searchWidget.btnPrevious, SIGNAL("clicked()"),
            self.find_previous)
        self.connect(self, SIGNAL("messageChanged(QString)"), self.message_end)
        self.connect(self._replaceWidget._btnCloseReplace, SIGNAL("clicked()"),
            lambda: self._replaceWidget.setVisible(False))
        self.connect(self._replaceWidget._btnReplace, SIGNAL("clicked()"),
            self.replace)
        self.connect(self._replaceWidget._btnReplaceAll, SIGNAL("clicked()"),
            self.replace_all)
        self.connect(self._shortEsc, SIGNAL("activated()"), self.hide_status)
        self.connect(self._fileSystemOpener.btnClose, SIGNAL("clicked()"),
            self.hide_status)
        self.connect(self._fileSystemOpener, SIGNAL("requestHide()"),
            self.hide_status)
Exemple #27
0
    def insertLayout(self):
        def createPixmapWidget(self, parent, iconName):
            w = QLabel(parent)
            parent.layout().addWidget(w)
            w.setFixedSize(16, 16)
            w.hide()
            if os.path.exists(iconName):
                w.setPixmap(QPixmap(iconName))
            return w

        self.setLayout(QVBoxLayout())
        self.layout().setMargin(2)

        self.topWidgetPart = gui.widgetBox(self, orientation="horizontal", margin=0)
        self.leftWidgetPart = gui.widgetBox(self.topWidgetPart, orientation="vertical", margin=0)
        if self.want_main_area:
            self.leftWidgetPart.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.MinimumExpanding))
            self.leftWidgetPart.updateGeometry()
            self.mainArea = gui.widgetBox(
                self.topWidgetPart,
                orientation="vertical",
                sizePolicy=QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding),
                margin=0,
            )
            self.mainArea.layout().setMargin(4)
            self.mainArea.updateGeometry()

        if self.want_control_area:
            self.controlArea = gui.widgetBox(self.leftWidgetPart, orientation="vertical", margin=4)

        if self.want_graph and self.show_save_graph:
            graphButtonBackground = gui.widgetBox(self.leftWidgetPart, orientation="horizontal", margin=4)
            self.graphButton = gui.button(graphButtonBackground, self, "&Save Graph")
            self.graphButton.setAutoDefault(0)

        if self.want_status_bar:
            self.widgetStatusArea = QFrame(self)
            self.statusBarIconArea = QFrame(self)
            self.widgetStatusBar = QStatusBar(self)

            self.layout().addWidget(self.widgetStatusArea)

            self.widgetStatusArea.setLayout(QHBoxLayout(self.widgetStatusArea))
            self.widgetStatusArea.layout().addWidget(self.statusBarIconArea)
            self.widgetStatusArea.layout().addWidget(self.widgetStatusBar)
            self.widgetStatusArea.layout().setMargin(0)
            self.widgetStatusArea.setFrameShape(QFrame.StyledPanel)

            self.statusBarIconArea.setLayout(QHBoxLayout())
            self.widgetStatusBar.setSizeGripEnabled(0)

            self.statusBarIconArea.hide()

            self._warningWidget = createPixmapWidget(
                self.statusBarIconArea, os.path.join(self.widgetDir, "icons/triangle-orange.png")
            )
            self._errorWidget = createPixmapWidget(
                self.statusBarIconArea, os.path.join(self.widgetDir + "icons/triangle-red.png")
            )
Exemple #28
0
    def __init__(self, settings, parent=None):
        super(MikiWindow, self).__init__(parent)
        self.setObjectName("mikiWindow")
        self.settings = settings
        self.notePath = settings.notePath

        ################ Setup core components ################
        self.notesTree = MikiTree(self)
        self.notesTree.setObjectName("notesTree")
        self.initTree(self.notePath, self.notesTree)
        self.notesTree.sortItems(0, Qt.AscendingOrder)

        self.ix = None
        self.setupWhoosh()

        self.viewedList = QToolBar(self.tr('Recently Viewed'), self)
        self.viewedList.setIconSize(QSize(16, 16))
        self.viewedList.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        self.viewedListActions = []
        self.noteSplitter = QSplitter(Qt.Horizontal)

        self.dockIndex = QDockWidget("Index")
        self.dockSearch = QDockWidget("Search")
        self.searchEdit = QLineEdit()
        self.searchView = MikiSearch(self)
        self.searchTab = QWidget()
        self.dockToc = QDockWidget("TOC")
        self.tocTree = TocTree()
        self.dockAttachment = QDockWidget("Attachment")
        self.attachmentView = AttachmentView(self)

        self.notesEdit = MikiEdit(self)
        self.notesEdit.setObjectName("notesEdit")
        MikiHighlighter(self.notesEdit)
        self.notesView = MikiView(self)

        self.findBar = QToolBar(self.tr('Find'), self)
        self.findBar.setFixedHeight(30)
        self.findEdit = QLineEdit(self.findBar)
        self.checkBox = QCheckBox(self.tr('Match case'), self.findBar)

        self.statusBar = QStatusBar(self)
        self.statusLabel = QLabel(self)

        self.altPressed = False


        ################ Setup actions ################
        self.actions = dict()
        self.setupActions()


        ################ Setup mainwindow ################
        self.setupMainWindow()

        # show changelogs after upgrade mikidown
        if self.settings.version < __version__:
            self.changelogHelp()
            self.settings.qsettings.setValue("version", __version__)
 def initStatusBar(self):
     """Init status bar"""
     # Status bar
     self.progress.connect(self.updateProgressBar)
     self.status.connect(self.updateStatusBar)
     self.statusBar = QStatusBar()
     progress = QProgressBar()
     self.statusBar.addPermanentWidget(progress)
 def __setup_statusbar(self):
     '''
     status bar setup - private method
     '''
     # status bar
     status_font = QFont("Helvetica [Cronyx]", 12)
     self.status_bar = QStatusBar(self)
     self.setStatusBar(self.status_bar)
     self.status_bar.setFont(status_font)
Exemple #31
0
    def __init__(self, base):
        QStatusBar.__init__(self)
        self.base = base
        self.status = self.LOADING

        style = "background-color: %s; border: 0px solid %s;" % (
            self.base.bgcolor, self.base.bgcolor)

        self.updates_button = ImageButton(base, 'dock-updates.png',
                                          i18n.get('update_status'))
        self.messages_button = ImageButton(base, 'dock-messages.png',
                                           i18n.get('send_direct_message'))
        self.search_button = ImageButton(base, 'dock-search.png',
                                         i18n.get('search'))
        self.settings_button = ImageButton(base, 'dock-preferences.png',
                                           i18n.get('settings'))

        self.updates_button.clicked.connect(self.__updates_clicked)
        self.messages_button.clicked.connect(self.__messages_clicked)
        self.search_button.clicked.connect(self.__search_clicked)
        self.settings_button.clicked.connect(self.__settings_clicked)

        separator = QWidget()
        separator.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)

        toolbar = QToolBar()
        toolbar.addWidget(self.settings_button)
        toolbar.addWidget(separator)
        toolbar.addWidget(self.search_button)
        toolbar.addWidget(self.messages_button)
        toolbar.addWidget(self.updates_button)
        toolbar.setMinimumHeight(30)
        toolbar.setContentsMargins(0, 0, 0, 0)
        toolbar.setStyleSheet(
            "QToolBar { %s }; QToolButton { %s opacity: 128; }; QToolButton:hover { %s opacity: 255;}"
            % (style, style, style))

        self.addPermanentWidget(toolbar, 1)
        self.setSizeGripEnabled(False)

        self.setContentsMargins(0, 0, 0, 0)
        self.setStyleSheet("QStatusBar { %s }" % style)
        self.loading()
Exemple #32
0
    def init_ui(self):
        wtitle = "Teigen " + self.version
        self.setWindowTitle(wtitle)
        self.mainLayout = QGridLayout(self)

        self.statusBar = QStatusBar()
        self.mainLayout.addWidget(self.statusBar, 10, 0, 1, 2)
        self.progressBar = QtGui.QProgressBar()
        self.progressBar.setRange(0, 10000)
        self.progressBar.setValue(0)

        self.ui_stop_button = QPushButton("Stop", self)
        self.ui_stop_button.clicked.connect(self.btnStop)

        self.statusBar.addWidget(self.progressBar)
        self.statusBar.addWidget(self.ui_stop_button)
        self.progressBar.show()

        self.configBarLayout = QGridLayout(self)
        self._ui_config_init()
Exemple #33
0
    def __init__(self, winged):
        QStatusBar.__init__(self)
        self.setSizeGripEnabled(False)
        self._winged = winged

        self.line = QLineEdit(self)
        #self.line.setMinimumWidth(250)
        self.btnClose = QPushButton(self.style().standardIcon(QStyle.SP_DialogCloseButton), '')
        self.btnFind = QPushButton(QIcon(config.images['find']), '')
        self.addWidget(self.btnClose)
        self.addWidget(self.line)
        self.addWidget(self.btnFind)

        self.shortEsc = QShortcut(QKeySequence(Qt.Key_Escape), self)

        self.connect(self.btnClose, SIGNAL("clicked()"), self.hide)
        self.connect(self.btnFind, SIGNAL("clicked()"), self.find)
        self.connect(self.line, SIGNAL("returnPressed()"), self.find)
        self.connect(self, SIGNAL("messageChanged(QString)"), self.message_end)
        self.connect(self.shortEsc, SIGNAL("activated()"), self.hide_status)
Exemple #34
0
    def __init__(self, parent=None):
        QStatusBar.__init__(self, parent)

        self._widgetStatus = QWidget()
        vbox = QVBoxLayout(self._widgetStatus)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        #Search Layout
        self._searchWidget = SearchWidget(self)
        vbox.addWidget(self._searchWidget)
        #Replace Layout
        self._replaceWidget = ReplaceWidget(self)
        vbox.addWidget(self._replaceWidget)
        self._replaceWidget.setVisible(False)
        #Code Locator
        self._codeLocator = locator.CodeLocatorWidget(self)
        vbox.addWidget(self._codeLocator)
        self._codeLocator.setVisible(False)
        #File system completer
        self._fileSystemOpener = FileSystemOpener()
        vbox.addWidget(self._fileSystemOpener)
        self._fileSystemOpener.setVisible(False)

        self.addWidget(self._widgetStatus)

        self._shortEsc = QShortcut(QKeySequence(Qt.Key_Escape), self)

        self.connect(self, SIGNAL("messageChanged(QString)"), self.message_end)
        self.connect(self._replaceWidget._btnCloseReplace, SIGNAL("clicked()"),
                     lambda: self._replaceWidget.setVisible(False))
        self.connect(self._replaceWidget._btnReplace, SIGNAL("clicked()"),
                     self.replace)
        self.connect(self._replaceWidget._btnReplaceAll, SIGNAL("clicked()"),
                     self.replace_all)
        self.connect(self._replaceWidget._btnReplaceSelection,
                     SIGNAL("clicked()"), self.replace_selected)
        self.connect(self._shortEsc, SIGNAL("activated()"), self.hide_status)
        self.connect(self._fileSystemOpener.btnClose, SIGNAL("clicked()"),
                     self.hide_status)
        self.connect(self._fileSystemOpener, SIGNAL("requestHide()"),
                     self.hide_status)
Exemple #35
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.dirty = False

        self.setObjectName("MainWindow")
        self.resize(800, 600)
        self.setWindowTitle("GA")  # TODO
        # TODO        app_icon = get_icon('OpenFisca22.png')
        #        self.setWindowIcon(app_icon)
        self.setLocale(QLocale(QLocale.French, QLocale.France))
        self.setDockOptions(QMainWindow.AllowNestedDocks
                            | QMainWindow.AllowTabbedDocks
                            | QMainWindow.AnimatedDocks)

        self.centralwidget = QWidget(self)
        self.gridLayout = QGridLayout(self.centralwidget)
        self.setCentralWidget(self.centralwidget)
        self.centralwidget.hide()

        self.statusbar = QStatusBar(self)
        self.statusbar.setObjectName("statusbar")
        self.setStatusBar(self.statusbar)

        # Showing splash screen
        pixmap = QPixmap(':/images/splash.png', 'png')
        self.splash = QSplashScreen(pixmap)
        font = self.splash.font()
        font.setPixelSize(10)
        self.splash.setFont(font)
        self.splash.show()
        self.splash.showMessage(
            "Initialisation...",
            Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute,
            QColor(Qt.black))
        #        if CONF.get('main', 'current_version', '') != __version__:
        #            CONF.set('main', 'current_version', __version__)
        # Execute here the actions to be performed only once after
        # each update (there is nothing there for now, but it could
        # be useful some day...

        self.start()
Exemple #36
0
    def setupUi(self) :
        "Setup the UI."
        self.info('Seting up the UI.')
        self.fileDialog = QFileDialog()
        self.fileDialog.setFileMode(QFileDialog.AnyFile)
        self.fileDialog.setViewMode(QFileDialog.Detail)

        self.loadButton = QPushButton( r'Open/New :', self)
        self.loadButton.setAutoDefault(False)

        self.textList = QListWidget(self)

        self.inputLine = tabEnabledLineEdit(self)

        self.toggleButton = QPushButton(r'Show/Hide', self)
        self.toggleButton.setAutoDefault(False)
        self.toggleButton.setCheckable(True)

        self.textLabel = QLabel()

        self.hBox = QHBoxLayout()
        self.hBox.addWidget(self.inputLine)
        self.hBox.addWidget(self.toggleButton)

        self.statusBar = QStatusBar(self)
        msg = 'Hello World! I love YOU!!!'
        self.statusBar.showMessage(msg, 5000)

        vBox = QVBoxLayout()
        items = [self.loadButton, self.textList, self.hBox, self.statusBar]
        for item in items :
            try :
                vBox.addWidget(item)
            except :
                vBox.addLayout(item)

        self.textViewer = QTextEdit()
        self.textViewer.setHidden(True)
        self.textViewer.setReadOnly(True)

        HBox = QHBoxLayout()

        items = [vBox, self.textViewer]
        for item in items :
            try :
                HBox.addWidget(item)
            except :
                HBox.addLayout(item)
                
        self.setLayout(HBox)
        self.resize(350, 500)
        self.setWindowTitle("VocVoc -- Your Vocabulary Helper")
        self.info('UI is set up now.')
Exemple #37
0
    def __init__(self, base):
        QStatusBar.__init__(self)
        self.base = base
        self.status = self.LOADING

        style = "background-color: %s; border: 0px solid %s;" % (self.base.bgcolor, self.base.bgcolor)

        self.updates_button = ImageButton(base, 'dock-updates.png',
                i18n.get('update_status'))
        self.messages_button = ImageButton(base, 'dock-messages.png',
                i18n.get('send_direct_message'))
        self.search_button = ImageButton(base, 'dock-search.png',
                i18n.get('search'))
        self.settings_button = ImageButton(base, 'dock-preferences.png',
                i18n.get('settings'))

        self.updates_button.clicked.connect(self.__updates_clicked)
        self.messages_button.clicked.connect(self.__messages_clicked)
        self.search_button.clicked.connect(self.__search_clicked)
        self.settings_button.clicked.connect(self.__settings_clicked)

        separator = QWidget()
        separator.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)

        toolbar = QToolBar()
        toolbar.addWidget(self.settings_button)
        toolbar.addWidget(separator)
        toolbar.addWidget(self.search_button)
        toolbar.addWidget(self.messages_button)
        toolbar.addWidget(self.updates_button)
        toolbar.setMinimumHeight(30)
        toolbar.setContentsMargins(0, 0, 0, 0)
        toolbar.setStyleSheet("QToolBar { %s }; QToolButton { %s opacity: 128; }; QToolButton:hover { %s opacity: 255;}" % (style, style, style))

        self.addPermanentWidget(toolbar, 1)
        self.setSizeGripEnabled(False)

        self.setContentsMargins(0, 0, 0, 0)
        self.setStyleSheet("QStatusBar { %s }" % style)
        self.loading()
Exemple #38
0
class Tab(QWidget):
    def __init__(self, parent, configuration):
        QWidget.__init__(self, parent)
        self._configuration = configuration

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        main_widget = QWidget(self)
        self._layout_main = QVBoxLayout()
        self._layout_main.setContentsMargins(0, 0, 0, 0)
        self._layout_main.setSpacing(6)
        main_widget.setLayout(self._layout_main)
        layout.addWidget(main_widget)
        self._status_bar = QStatusBar()
        layout.addWidget(self._status_bar)
        self.setLayout(layout)

    def _add_widget(self, widget):
        self._layout_main.addWidget(widget)

    def set_error_message(self, msg):
        self._status_bar.showMessage(msg)
    def create_status_bar ( self, parent ):
        """ Creates a status bar. """

        if self.status_bar is None:
            self.status_bar = QStatusBar( parent )
            self.status_bar.setSizeGripEnabled( False )

            if len( self.messages ) > 1:
                self._show_messages()
            else:
                self.status_bar.showMessage( self.message )

        return self.status_bar
Exemple #40
0
 def _setupUi(self):
     self.setWindowTitle(tr("{} Results").format(self.app.NAME))
     self.resize(630, 514)
     self.centralwidget = QWidget(self)
     self.verticalLayout = QVBoxLayout(self.centralwidget)
     self.verticalLayout.setMargin(0)
     self.verticalLayout.setSpacing(0)
     self.actionsButton = QPushButton(tr("Actions"))
     self.detailsButton = QPushButton(tr("Details"))
     self.dupesOnlyCheckBox = QCheckBox(tr("Dupes Only"))
     self.deltaValuesCheckBox = QCheckBox(tr("Delta Values"))
     self.searchEdit = SearchEdit()
     self.searchEdit.setMaximumWidth(300)
     self.horizontalLayout = horizontalWrap([self.actionsButton, self.detailsButton,
         self.dupesOnlyCheckBox, self.deltaValuesCheckBox, None, self.searchEdit, 8])
     self.horizontalLayout.setSpacing(8)
     self.verticalLayout.addLayout(self.horizontalLayout)
     self.resultsView = ResultsView(self.centralwidget)
     self.resultsView.setSelectionMode(QAbstractItemView.ExtendedSelection)
     self.resultsView.setSelectionBehavior(QAbstractItemView.SelectRows)
     self.resultsView.setSortingEnabled(True)
     self.resultsView.verticalHeader().setVisible(False)
     h = self.resultsView.horizontalHeader()
     h.setHighlightSections(False)
     h.setMovable(True)
     h.setStretchLastSection(False)
     h.setDefaultAlignment(Qt.AlignLeft)
     self.verticalLayout.addWidget(self.resultsView)
     self.setCentralWidget(self.centralwidget)
     self._setupActions()
     self._setupMenu()
     self.statusbar = QStatusBar(self)
     self.statusbar.setSizeGripEnabled(True)
     self.setStatusBar(self.statusbar)
     self.statusLabel = QLabel(self)
     self.statusbar.addPermanentWidget(self.statusLabel, 1)
     
     if self.app.prefs.resultWindowIsMaximized:
         self.setWindowState(self.windowState() | Qt.WindowMaximized)
     else:
         if self.app.prefs.resultWindowRect is not None:
             self.setGeometry(self.app.prefs.resultWindowRect)
         else:
             moveToScreenCenter(self)
    def __init__(self, showEmptyDatasetNodes = False, parent=None):
        super(Visor, self).__init__(parent)
        self.setupUi(self)

        self.controller = VisorController.VisorController()
        self.controller.threddsServerMapObjectRetrieved.connect(self.onNewDatasetsAvailable)
        self.controller.threddsDataSetUpdated.connect(self.onDataSetUpdated)
        self.controller.mapImageRetrieved.connect(self.showNewImage)
        self.controller.standardMessage.connect(self.postInformationMessageToUser)
        self.controller.errorMessage.connect(self.postCriticalErrorToUser)
        self.controller.mapInfoRetrieved.connect(self._onMapInfoReceivedFromController)
        self.controller.batchDownloadFinished.connect(self.createLayerGroup)

        self.showEmptyDatasetNodes = showEmptyDatasetNodes #TODO: Self-explanatory...
        self.combo_dataset_list.currentIndexChanged.connect(self._onDataSetItemChanged)
        self.tree_widget.itemClicked.connect(self._onMapTreeWidgetItemClicked)
        self.tree_widget.itemExpanded.connect(self._onMapTreeWidgetItemExpanded)
        self.connect(self.combo_wcs_coverage, SIGNAL("currentIndexChanged(const QString&)"), self._onCoverageSelectorItemChanged)
        self.connect(self.combo_wms_layer, SIGNAL("currentIndexChanged(const QString&)"), self._onWMSLayerSelectorItemChanged)
        self.connect(self.combo_wms_style_type, SIGNAL("currentIndexChanged(const QString&)"), self._onWMSStyleTypeSelectorItemChanged)
        self.connect(self.combo_wms_time, SIGNAL("currentIndexChanged(int)"), self._onWMSFirstTimeChanged)
        self.connect(self.combo_wcs_time, SIGNAL("currentIndexChanged(int)"), self._onWCSFirstTimeChanged)

        self.button_req_map.clicked.connect(self._onbuttonReqMapClicked)
        #self.actionToggleAlwaysOnTop.toggled.connect(self._onAlwaysOnTopPrefsChanged)
        self.buttonManageServers.clicked.connect(self._onManageServersRequested)
        self.button_req_animation.clicked.connect(self.toggleAnimationMenu)

        #We add a status bar to this QDockWidget
        self.statusbar = QStatusBar()
        self.gridLayout.addWidget(self.statusbar)

        self.datasetInUse = None
        self.uiAnimation = None
        self.currentMap = None
        self.wcsAvailableTimes = []
        self.wmsAvailableTimes = []

        self.firstRunThisSession = True
Exemple #42
0
 def addWidgets(self):
     layout = QVBoxLayout()
     self.setLayout(layout)
     layout.setSpacing(0)
     layout.setContentsMargins(0, 0, 0, 0)
     hbox = QHBoxLayout()
     hbox.setSpacing(4)
     hbox.setContentsMargins(8, 8, 8, 2)
     searchbox = SearchEditor()
     hbox.addWidget(searchbox)
     self.searchbox = searchbox
     menu = MenuButton(self)
     hbox.addWidget(menu)
     layout.addLayout(hbox)
     pwview = VaultView(self)
     searchbox.textChanged.connect(pwview.setSearchQuery)
     pwview.currentVaultChanged.connect(searchbox.currentVaultChanged)
     pwview.currentVaultItemCountChanged.connect(
         searchbox.currentVaultItemCountChanged)
     layout.addWidget(pwview)
     self.pwview = pwview
     hbox = QHBoxLayout()
     addbutton = AddButton()
     pwview.currentVaultChanged.connect(addbutton.currentVaultChanged)
     hbox.addWidget(addbutton)
     frame = QFrame()
     frame.setFrameStyle(QFrame.VLine | QFrame.Raised)
     frame.setLineWidth(1)
     frame.setFixedHeight(26)
     hbox.addWidget(frame)
     statusbar = QStatusBar()
     hbox.addWidget(statusbar)
     self.statusbar = statusbar
     self.sink = QWidget()
     self.sink.setFocusPolicy(Qt.ClickFocus)
     self.sink.resize(0, 0)
     hbox.addWidget(self.sink)
     layout.addLayout(hbox)
Exemple #43
0
        def setupUi(self, MainWindow):
            """
            """
            MainWindow.resize(100, 200)
            #Create central widget and add a Layout
            self.centralwidget = QWidget(MainWindow)
            MainWindow.setCentralWidget(self.centralwidget)
            self.verticalLayout = QVBoxLayout(self.centralwidget)

            # Add a Temperature sensor and Label Widgets
            self.t1 = QFellesController(self.centralwidget)

            # Add Widgets to Layout
            self.verticalLayout.addWidget(self.t1)

            # Create the Menu bar
            self.menubar = QMenuBar(MainWindow)
            MainWindow.setMenuBar(self.menubar)
            # Create the Status Bar
            self.statusbar = QStatusBar(MainWindow)
            MainWindow.setStatusBar(self.statusbar)

            self.retranslateUi(MainWindow)
Exemple #44
0
    def __init__(self, parent = None):
        super(MainWindow, self).__init__(parent)
        self.dirty = False

        self.setObjectName("MainWindow")
        self.resize(800, 600)
        self.setWindowTitle("GA")   # TODO
# TODO        app_icon = get_icon('OpenFisca22.png')
#        self.setWindowIcon(app_icon)
        self.setLocale(QLocale(QLocale.French, QLocale.France))
        self.setDockOptions(QMainWindow.AllowNestedDocks|QMainWindow.AllowTabbedDocks|QMainWindow.AnimatedDocks)

        self.centralwidget = QWidget(self)
        self.gridLayout = QGridLayout(self.centralwidget)
        self.setCentralWidget(self.centralwidget)
        self.centralwidget.hide()

        self.statusbar = QStatusBar(self)
        self.statusbar.setObjectName("statusbar")
        self.setStatusBar(self.statusbar)

        # Showing splash screen
        pixmap = QPixmap(':/images/splash.png', 'png')
        self.splash = QSplashScreen(pixmap)
        font = self.splash.font()
        font.setPixelSize(10)
        self.splash.setFont(font)
        self.splash.show()
        self.splash.showMessage("Initialisation...", Qt.AlignBottom | Qt.AlignCenter | 
                                Qt.AlignAbsolute, QColor(Qt.black))
#        if CONF.get('main', 'current_version', '') != __version__:
#            CONF.set('main', 'current_version', __version__)
            # Execute here the actions to be performed only once after
            # each update (there is nothing there for now, but it could 
            # be useful some day...
        
        self.start()
Exemple #45
0
 def setupUi(self, port):
     self.setObjectName("MainWindow")
     self.resize(600, 600)
     self.centralwidget = QWidget(self)
     p = self.centralwidget.palette()
     self.centralwidget.setAutoFillBackground(True)
     p.setColor(self.centralwidget.backgroundRole(), QColor(126, 135, 152))
     self.centralwidget.setPalette(p)
     self.centralwidget.setObjectName("centralwidget")
     self.gridLayout = QGridLayout(self.centralwidget)
     self.gridLayout.setObjectName("gridLayout")
     self.setCentralWidget(self.centralwidget)
     self.menubar = QMenuBar(self)
     self.menubar.setGeometry(QRect(0, 0, 808, 25))
     self.menubar.setObjectName("menubar")
     self.menuFile = QMenu(self.menubar)
     self.menuFile.setObjectName("menuFile")
     self.setMenuBar(self.menubar)
     self.statusbar = QStatusBar(self)
     self.statusbar.setObjectName("statusbar")
     self.setStatusBar(self.statusbar)
     self.actionQuit = QAction(self)
     self.actionQuit.setObjectName("actionQuit")
     self.menuFile.addSeparator()
     self.menuFile.addAction(self.actionQuit)
     self.menubar.addAction(self.menuFile.menuAction())
     self.actionReset = QAction(self)
     self.actionReset.setObjectName("reset")
     self.menuFile.addSeparator()
     self.menuFile.addAction(self.actionReset)
     self.menubar.addAction(self.menuFile.menuAction())
     # add other GUI objects
     self.graph_widget = GraphWidget(self.statusbar)
     self.gridLayout.addWidget(self.graph_widget, 1, 11, 10, 10)
     pixmap = QPixmap(':/images/cta-logo-mini.png')
     lbl = QLabel()
     lbl.setPixmap(pixmap)
     self.gridLayout.addWidget(lbl, 0, 0)
     p = self.graph_widget.palette()
     self.graph_widget.setAutoFillBackground(True)
     p.setColor(self.graph_widget.backgroundRole(),
                QColor(255, 255, 255))  # QColor(226, 235, 252))
     self.graph_widget.setPalette(p)
     self.quitButton = QPushButton()  # self.centralwidget)
     self.quitButton.setObjectName("quitButton")
     self.quitButton.setText(
         QApplication.translate("MainWindow", "Quit", None,
                                QApplication.UnicodeUTF8))
     self.gridLayout.addWidget(self.quitButton, 12, 0, 1, 1)
     self.info_label = InfoLabel(0, 4)
     self.info_label.setAutoFillBackground(True)
     self.gridLayout.addWidget(self.info_label, 1, 0, 1, 5)
     #self.info_label.setAlignment(PyQt4.Qt.AlignCenter);
     palette = QPalette()
     palette.setColor(self.info_label.backgroundRole(), Qt.lightGray)
     self.info_label.setPalette(palette)
     QObject.connect(self.quitButton, SIGNAL("clicked()"), self.stop)
     QObject.connect(self.actionQuit, SIGNAL("triggered()"), self.stop)
     QMetaObject.connectSlotsByName(self)
     self.retranslateUi()
     QObject.connect(self.actionQuit, SIGNAL("triggered()"), self.close)
     QMetaObject.connectSlotsByName(self)
     # Create GuiConnexion for ZMQ comminucation with pipeline
     self.guiconnection = GuiConnexion(gui_port=port,
                                       statusBar=self.statusbar)
     self.guiconnection.message.connect(self.graph_widget.pipechange)
     self.guiconnection.message.connect(self.info_label.pipechange)
     self.guiconnection.reset_message.connect(self.graph_widget.reset)
     self.guiconnection.reset_message.connect(self.info_label.reset)
     self.guiconnection.mode_message.connect(self.info_label.mode_receive)
     QObject.connect(self.actionReset, SIGNAL("triggered()"),
                     self.guiconnection.reset)
     QMetaObject.connectSlotsByName(self)
     # start the process
     self.guiconnection.start()
Exemple #46
0
class MainWindow(QMainWindow, object):
    """
    QMainWindow displays pipeline
    Parameters
    ----------
    port : str
        used port to communicate with pipeline
        Note: The firewall must be configure to accept input/output on this port
    """
    def __init__(self, port):
        super(MainWindow, self).__init__()
        self.setupUi(port)

    def setupUi(self, port):
        self.setObjectName("MainWindow")
        self.resize(600, 600)
        self.centralwidget = QWidget(self)
        p = self.centralwidget.palette()
        self.centralwidget.setAutoFillBackground(True)
        p.setColor(self.centralwidget.backgroundRole(), QColor(126, 135, 152))
        self.centralwidget.setPalette(p)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout = QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(self)
        self.menubar.setGeometry(QRect(0, 0, 808, 25))
        self.menubar.setObjectName("menubar")
        self.menuFile = QMenu(self.menubar)
        self.menuFile.setObjectName("menuFile")
        self.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(self)
        self.statusbar.setObjectName("statusbar")
        self.setStatusBar(self.statusbar)
        self.actionQuit = QAction(self)
        self.actionQuit.setObjectName("actionQuit")
        self.menuFile.addSeparator()
        self.menuFile.addAction(self.actionQuit)
        self.menubar.addAction(self.menuFile.menuAction())
        self.actionReset = QAction(self)
        self.actionReset.setObjectName("reset")
        self.menuFile.addSeparator()
        self.menuFile.addAction(self.actionReset)
        self.menubar.addAction(self.menuFile.menuAction())
        # add other GUI objects
        self.graph_widget = GraphWidget(self.statusbar)
        self.gridLayout.addWidget(self.graph_widget, 1, 11, 10, 10)
        pixmap = QPixmap(':/images/cta-logo-mini.png')
        lbl = QLabel()
        lbl.setPixmap(pixmap)
        self.gridLayout.addWidget(lbl, 0, 0)
        p = self.graph_widget.palette()
        self.graph_widget.setAutoFillBackground(True)
        p.setColor(self.graph_widget.backgroundRole(),
                   QColor(255, 255, 255))  # QColor(226, 235, 252))
        self.graph_widget.setPalette(p)
        self.quitButton = QPushButton()  # self.centralwidget)
        self.quitButton.setObjectName("quitButton")
        self.quitButton.setText(
            QApplication.translate("MainWindow", "Quit", None,
                                   QApplication.UnicodeUTF8))
        self.gridLayout.addWidget(self.quitButton, 12, 0, 1, 1)
        self.info_label = InfoLabel(0, 4)
        self.info_label.setAutoFillBackground(True)
        self.gridLayout.addWidget(self.info_label, 1, 0, 1, 5)
        #self.info_label.setAlignment(PyQt4.Qt.AlignCenter);
        palette = QPalette()
        palette.setColor(self.info_label.backgroundRole(), Qt.lightGray)
        self.info_label.setPalette(palette)
        QObject.connect(self.quitButton, SIGNAL("clicked()"), self.stop)
        QObject.connect(self.actionQuit, SIGNAL("triggered()"), self.stop)
        QMetaObject.connectSlotsByName(self)
        self.retranslateUi()
        QObject.connect(self.actionQuit, SIGNAL("triggered()"), self.close)
        QMetaObject.connectSlotsByName(self)
        # Create GuiConnexion for ZMQ comminucation with pipeline
        self.guiconnection = GuiConnexion(gui_port=port,
                                          statusBar=self.statusbar)
        self.guiconnection.message.connect(self.graph_widget.pipechange)
        self.guiconnection.message.connect(self.info_label.pipechange)
        self.guiconnection.reset_message.connect(self.graph_widget.reset)
        self.guiconnection.reset_message.connect(self.info_label.reset)
        self.guiconnection.mode_message.connect(self.info_label.mode_receive)
        QObject.connect(self.actionReset, SIGNAL("triggered()"),
                        self.guiconnection.reset)
        QMetaObject.connectSlotsByName(self)
        # start the process
        self.guiconnection.start()

    def retranslateUi(self):
        self.setWindowTitle(
            QApplication.translate("ctapipe flow based GUI",
                                   "ctapipe flow based GUI", None,
                                   QApplication.UnicodeUTF8))
        self.menuFile.setTitle(
            QApplication.translate("MainWindow", "File", None,
                                   QApplication.UnicodeUTF8))
        self.actionQuit.setText(
            QApplication.translate("MainWindow", "Quit", None,
                                   QApplication.UnicodeUTF8))
        self.actionReset.setText(
            QApplication.translate("MainWindow", "Reset", None,
                                   QApplication.UnicodeUTF8))

    def stop(self):
        """Method connect (via Qt slot) to exit button
        Stops self.guiconnection (for ZMQ communication) process.
        Close main_windows
        """
        self.guiconnection.finish()
        self.guiconnection.join()
        self.close()

    def closeEvent(self, event):
        self.guiconnection.finish()
        self.guiconnection.join()
        event.accept()  # let the window close
Exemple #47
0
 def showMessage(self, message, timeout):
     self._widgetStatus.hide()
     self._replaceWidget.setVisible(False)
     self.show()
     QStatusBar.showMessage(self, message, timeout)
Exemple #48
0
 def showMessage(self, message, timeout):
     self._widgetStatus.hide()
     self._replaceWidget.setVisible(False)
     self.show()
     QStatusBar.showMessage(self, message, timeout)
Exemple #49
0
 def showMessage(self, message, timeout):
     if settings.SHOW_STATUS_NOTIFICATIONS:
         self._widgetStatus.hide()
         self._replaceWidget.setVisible(False)
         self.show()
         QStatusBar.showMessage(self, message, timeout)
Exemple #50
0
    def __init__(self, settings, parent=None):
        super(MikiWindow, self).__init__(parent)
        self.setObjectName("mikiWindow")
        self.settings = settings
        self.notePath = settings.notePath
        lockPath = os.path.join(settings.notebookPath, '.mikidown_lock')
        if not os.path.exists(lockPath):
            self.lockPathFH = os.open(lockPath,
                                      os.O_CREAT | os.O_EXCL | os.O_RDWR)
        ################ Setup core components ################
        self.notesTree = MikiTree(self)
        self.quickNoteNav = QLineEdit()
        self.notesTab = QWidget()
        self.completer = SlashPleter()
        self.completer.setModel(self.notesTree.model())
        self.quickNoteNav.setCompleter(self.completer)
        self.notesTree.setObjectName("notesTree")
        self.initTree(self.notePath, self.notesTree)
        self.notesTree.sortItems(0, Qt.AscendingOrder)

        self.ix = None
        self.setupWhoosh()

        self.viewedList = QToolBar(self.tr('Recently Viewed'), self)
        self.viewedList.setIconSize(QSize(16, 16))
        self.viewedList.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        self.viewedListActions = []
        self.noteSplitter = QSplitter(Qt.Horizontal)

        self.dockIndex = QDockWidget(self.tr("Index"))
        self.dockSearch = QDockWidget(self.tr("Search"))
        self.searchEdit = QLineEdit()
        self.searchView = MikiSearch(self)
        self.searchTab = QWidget()
        self.dockToc = QDockWidget(self.tr("TOC"))
        self.tocTree = TocTree()
        self.dockAttachment = QDockWidget(self.tr("Attachment"))
        self.attachmentView = AttachmentView(self)

        self.notesEdit = MikiEdit(self)
        self.notesEdit.setObjectName(self.tr("notesEdit"))
        self.loadHighlighter()
        self.notesView = MikiView(self)

        self.findBar = QToolBar(self.tr('Find'), self)
        self.findBar.setFixedHeight(30)
        self.findEdit = QLineEdit(self.findBar)
        self.checkBox = QCheckBox(self.tr('Match case'), self.findBar)

        self.statusBar = QStatusBar(self)
        self.statusLabel = QLabel(self)

        self.altPressed = False

        ################ Setup actions ################
        self.actions = dict()
        self.setupActions()

        ################ Setup mainwindow ################
        self.setupMainWindow()

        # show changelogs after upgrade mikidown
        if self.settings.version < __version__ or Mikibook.settings.value(
                "version", defaultValue="0") < __version__:
            self.changelogHelp()
            self.settings.qsettings.setValue("version", __version__)
            Mikibook.settings.setValue("version", __version__)
Exemple #51
0
 def show(self):
     self.clearMessage()
     QStatusBar.show(self)
     if self._widgetStatus.isVisible():
         self._searchWidget._line.setFocus()
         self._searchWidget._line.selectAll()
    def createStatusBar(self):
        """create status bar"""

        self.statusbar = QStatusBar(self)
        self.setStatusBar(self.statusbar)
Exemple #53
0
    def insertLayout(self):
        def createPixmapWidget(self, parent, iconName):
            w = QLabel(parent)
            parent.layout().addWidget(w)
            w.setFixedSize(16, 16)
            w.hide()
            if os.path.exists(iconName):
                w.setPixmap(QPixmap(iconName))
            return w

        self.setLayout(QVBoxLayout())
        self.layout().setMargin(2)

        self.warning_bar = gui.widgetBox(self,
                                         orientation="horizontal",
                                         margin=0,
                                         spacing=0)
        self.warning_icon = gui.widgetLabel(self.warning_bar, "")
        self.warning_label = gui.widgetLabel(self.warning_bar, "")
        self.warning_label.setStyleSheet("padding-top: 5px")
        self.warning_bar.setSizePolicy(QSizePolicy.Ignored,
                                       QSizePolicy.Maximum)
        gui.rubber(self.warning_bar)
        self.warning_bar.setVisible(False)

        self.topWidgetPart = gui.widgetBox(self,
                                           orientation="horizontal",
                                           margin=0)
        self.leftWidgetPart = gui.widgetBox(self.topWidgetPart,
                                            orientation="vertical",
                                            margin=0)
        if self.want_main_area:
            self.leftWidgetPart.setSizePolicy(
                QSizePolicy(QSizePolicy.Fixed, QSizePolicy.MinimumExpanding))
            self.leftWidgetPart.updateGeometry()
            self.mainArea = gui.widgetBox(self.topWidgetPart,
                                          orientation="vertical",
                                          sizePolicy=QSizePolicy(
                                              QSizePolicy.Expanding,
                                              QSizePolicy.Expanding),
                                          margin=0)
            self.mainArea.layout().setMargin(4)
            self.mainArea.updateGeometry()

        if self.want_control_area:
            self.controlArea = gui.widgetBox(self.leftWidgetPart,
                                             orientation="vertical",
                                             margin=4)

        if self.want_graph and self.show_save_graph:
            graphButtonBackground = gui.widgetBox(self.leftWidgetPart,
                                                  orientation="horizontal",
                                                  margin=4)
            self.graphButton = gui.button(graphButtonBackground, self,
                                          "&Save Graph")
            self.graphButton.setAutoDefault(0)

        if self.want_status_bar:
            self.widgetStatusArea = QFrame(self)
            self.statusBarIconArea = QFrame(self)
            self.widgetStatusBar = QStatusBar(self)

            self.layout().addWidget(self.widgetStatusArea)

            self.widgetStatusArea.setLayout(QHBoxLayout(self.widgetStatusArea))
            self.widgetStatusArea.layout().addWidget(self.statusBarIconArea)
            self.widgetStatusArea.layout().addWidget(self.widgetStatusBar)
            self.widgetStatusArea.layout().setMargin(0)
            self.widgetStatusArea.setFrameShape(QFrame.StyledPanel)

            self.statusBarIconArea.setLayout(QHBoxLayout())
            self.widgetStatusBar.setSizeGripEnabled(0)

            self.statusBarIconArea.hide()

            self._warningWidget = createPixmapWidget(
                self.statusBarIconArea,
                os.path.join(environ.widget_install_dir,
                             "icons/triangle-orange.png"))
            self._errorWidget = createPixmapWidget(
                self.statusBarIconArea,
                os.path.join(environ.widget_install_dir,
                             "icons/triangle-red.png"))
Exemple #54
0
class OWWidget(QDialog, metaclass=WidgetMetaClass):
    # Global widget count
    widget_id = 0

    # Widget description
    name = None
    id = None
    category = None
    version = None
    description = None
    long_description = None
    icon = "icons/Unknown.png"
    priority = sys.maxsize
    author = None
    author_email = None
    maintainer = None
    maintainer_email = None
    help = None
    help_ref = None
    url = None
    keywords = []
    background = None
    replaces = None
    inputs = []
    outputs = []

    # Default widget layout settings
    want_basic_layout = True
    want_main_area = True
    want_control_area = True
    want_graph = False
    show_save_graph = True
    want_status_bar = False
    no_report = False

    save_position = True
    resizing_enabled = True

    widgetStateChanged = Signal(str, int, str)
    blockingStateChanged = Signal(bool)
    asyncCallsStateChange = Signal()
    progressBarValueChanged = Signal(float)
    processingStateChanged = Signal(int)

    settingsHandler = None
    """:type: SettingsHandler"""

    savedWidgetGeometry = settings.Setting(None)

    def __new__(cls, parent=None, *args, **kwargs):
        self = super().__new__(cls, None, cls.get_flags())
        QDialog.__init__(self, None, self.get_flags())

        stored_settings = kwargs.get('stored_settings', None)
        if self.settingsHandler:
            self.settingsHandler.initialize(self, stored_settings)

        self.signalManager = kwargs.get('signal_manager', None)

        setattr(self, gui.CONTROLLED_ATTRIBUTES,
                ControlledAttributesDict(self))
        self._guiElements = []  # used for automatic widget debugging
        self.__reportData = None

        # TODO: position used to be saved like this. Reimplement.
        #if save_position:
        #    self.settingsList = getattr(self, "settingsList", []) + \
        #                        ["widgetShown", "savedWidgetGeometry"]

        OWWidget.widget_id += 1
        self.widget_id = OWWidget.widget_id

        if self.name:
            self.setCaption(self.name)

        self.setFocusPolicy(Qt.StrongFocus)

        self.startTime = time.time()  # used in progressbar

        self.widgetState = {"Info": {}, "Warning": {}, "Error": {}}

        self.__blocking = False
        # flag indicating if the widget's position was already restored
        self.__was_restored = False

        self.__progressBarValue = -1
        self.__progressState = 0
        self.__statusMessage = ""

        if self.want_basic_layout:
            self.insertLayout()

        return self

    def __init__(self, *args, **kwargs):
        """QDialog __init__ was already called in __new__,
        please do not call it here."""

    @classmethod
    def get_flags(cls):
        return (Qt.Window if cls.resizing_enabled else Qt.Dialog
                | Qt.MSWindowsFixedSizeDialogHint)

    # noinspection PyAttributeOutsideInit
    def insertLayout(self):
        def createPixmapWidget(self, parent, iconName):
            w = QLabel(parent)
            parent.layout().addWidget(w)
            w.setFixedSize(16, 16)
            w.hide()
            if os.path.exists(iconName):
                w.setPixmap(QPixmap(iconName))
            return w

        self.setLayout(QVBoxLayout())
        self.layout().setMargin(2)

        self.warning_bar = gui.widgetBox(self,
                                         orientation="horizontal",
                                         margin=0,
                                         spacing=0)
        self.warning_icon = gui.widgetLabel(self.warning_bar, "")
        self.warning_label = gui.widgetLabel(self.warning_bar, "")
        self.warning_label.setStyleSheet("padding-top: 5px")
        self.warning_bar.setSizePolicy(QSizePolicy.Ignored,
                                       QSizePolicy.Maximum)
        gui.rubber(self.warning_bar)
        self.warning_bar.setVisible(False)

        self.topWidgetPart = gui.widgetBox(self,
                                           orientation="horizontal",
                                           margin=0)
        self.leftWidgetPart = gui.widgetBox(self.topWidgetPart,
                                            orientation="vertical",
                                            margin=0)
        if self.want_main_area:
            self.leftWidgetPart.setSizePolicy(
                QSizePolicy(QSizePolicy.Fixed, QSizePolicy.MinimumExpanding))
            self.leftWidgetPart.updateGeometry()
            self.mainArea = gui.widgetBox(self.topWidgetPart,
                                          orientation="vertical",
                                          sizePolicy=QSizePolicy(
                                              QSizePolicy.Expanding,
                                              QSizePolicy.Expanding),
                                          margin=0)
            self.mainArea.layout().setMargin(4)
            self.mainArea.updateGeometry()

        if self.want_control_area:
            self.controlArea = gui.widgetBox(self.leftWidgetPart,
                                             orientation="vertical",
                                             margin=4)

        if self.want_graph and self.show_save_graph:
            graphButtonBackground = gui.widgetBox(self.leftWidgetPart,
                                                  orientation="horizontal",
                                                  margin=4)
            self.graphButton = gui.button(graphButtonBackground, self,
                                          "&Save Graph")
            self.graphButton.setAutoDefault(0)

        if self.want_status_bar:
            self.widgetStatusArea = QFrame(self)
            self.statusBarIconArea = QFrame(self)
            self.widgetStatusBar = QStatusBar(self)

            self.layout().addWidget(self.widgetStatusArea)

            self.widgetStatusArea.setLayout(QHBoxLayout(self.widgetStatusArea))
            self.widgetStatusArea.layout().addWidget(self.statusBarIconArea)
            self.widgetStatusArea.layout().addWidget(self.widgetStatusBar)
            self.widgetStatusArea.layout().setMargin(0)
            self.widgetStatusArea.setFrameShape(QFrame.StyledPanel)

            self.statusBarIconArea.setLayout(QHBoxLayout())
            self.widgetStatusBar.setSizeGripEnabled(0)

            self.statusBarIconArea.hide()

            self._warningWidget = createPixmapWidget(
                self.statusBarIconArea,
                os.path.join(environ.widget_install_dir,
                             "icons/triangle-orange.png"))
            self._errorWidget = createPixmapWidget(
                self.statusBarIconArea,
                os.path.join(environ.widget_install_dir,
                             "icons/triangle-red.png"))

    # status bar handler functions
    def setState(self, stateType, id, text):
        stateChanged = super().setState(stateType, id, text)
        if not stateChanged or not hasattr(self, "widgetStatusArea"):
            return

        iconsShown = 0
        warnings = [("Warning", self._warningWidget, self._owWarning),
                    ("Error", self._errorWidget, self._owError)]
        for state, widget, use in warnings:
            if not widget:
                continue
            if use and self.widgetState[state]:
                widget.setToolTip("\n".join(self.widgetState[state].values()))
                widget.show()
                iconsShown = 1
            else:
                widget.setToolTip("")
                widget.hide()

        if iconsShown:
            self.statusBarIconArea.show()
        else:
            self.statusBarIconArea.hide()

        if (stateType == "Warning" and self._owWarning) or \
                (stateType == "Error" and self._owError):
            if text:
                self.setStatusBarText(stateType + ": " + text)
            else:
                self.setStatusBarText("")
        self.updateStatusBarState()

    def updateWidgetStateInfo(self, stateType, id, text):
        html = self.widgetStateToHtml(self._owInfo, self._owWarning,
                                      self._owError)
        if html:
            self.widgetStateInfoBox.show()
            self.widgetStateInfo.setText(html)
            self.widgetStateInfo.setToolTip(html)
        else:
            if not self.widgetStateInfoBox.isVisible():
                dHeight = -self.widgetStateInfoBox.height()
            else:
                dHeight = 0
            self.widgetStateInfoBox.hide()
            self.widgetStateInfo.setText("")
            self.widgetStateInfo.setToolTip("")
            width, height = self.width(), self.height() + dHeight
            self.resize(width, height)

    def updateStatusBarState(self):
        if not hasattr(self, "widgetStatusArea"):
            return
        if self.widgetState["Warning"] or self.widgetState["Error"]:
            self.widgetStatusArea.show()
        else:
            self.widgetStatusArea.hide()

    def setStatusBarText(self, text, timeout=5000):
        if hasattr(self, "widgetStatusBar"):
            self.widgetStatusBar.showMessage(" " + text, timeout)

    # TODO add!
    def prepareDataReport(self, data):
        pass

    # ##############################################
    """
    def isDataWithClass(self, data, wantedVarType=None, checkMissing=False):
        self.error([1234, 1235, 1236])
        if not data:
            return 0
        if not data.domain.classVar:
            self.error(1234, "A data set with a class attribute is required.")
            return 0
        if wantedVarType and data.domain.classVar.varType != wantedVarType:
            self.error(1235, "Unable to handle %s class." %
                             str(data.domain.class_var.var_type).lower())
            return 0
        if checkMissing and not orange.Preprocessor_dropMissingClasses(data):
            self.error(1236, "Unable to handle data set with no known classes")
            return 0
        return 1
    """

    def restoreWidgetPosition(self):
        restored = False
        if self.save_position:
            geometry = self.savedWidgetGeometry
            if geometry is not None:
                restored = self.restoreGeometry(QByteArray(geometry))

            if restored:
                space = qApp.desktop().availableGeometry(self)
                frame, geometry = self.frameGeometry(), self.geometry()

                #Fix the widget size to fit inside the available space
                width = space.width() - (frame.width() - geometry.width())
                width = min(width, geometry.width())
                height = space.height() - (frame.height() - geometry.height())
                height = min(height, geometry.height())
                self.resize(width, height)

                # Move the widget to the center of available space if it is
                # currently outside it
                if not space.contains(self.frameGeometry()):
                    x = max(0, space.width() / 2 - width / 2)
                    y = max(0, space.height() / 2 - height / 2)

                    self.move(x, y)
        return restored

    def __updateSavedGeometry(self):
        if self.__was_restored:
            # Update the saved geometry only between explicit show/hide
            # events (i.e. changes initiated by the user not by Qt's default
            # window management).
            self.savedWidgetGeometry = self.saveGeometry()

    # when widget is resized, save the new width and height
    def resizeEvent(self, ev):
        QDialog.resizeEvent(self, ev)
        # Don't store geometry if the widget is not visible
        # (the widget receives a resizeEvent (with the default sizeHint)
        # before showEvent and we must not overwrite the the savedGeometry
        # with it)
        if self.save_position and self.isVisible():
            self.__updateSavedGeometry()

    def moveEvent(self, ev):
        QDialog.moveEvent(self, ev)
        if self.save_position and self.isVisible():
            self.__updateSavedGeometry()

    # set widget state to hidden
    def hideEvent(self, ev):
        if self.save_position:
            self.__updateSavedGeometry()
        self.__was_restored = False
        QDialog.hideEvent(self, ev)

    def closeEvent(self, ev):
        if self.save_position and self.isVisible():
            self.__updateSavedGeometry()
        self.__was_restored = False
        QDialog.closeEvent(self, ev)

    def showEvent(self, ev):
        QDialog.showEvent(self, ev)
        if self.save_position:
            # Restore saved geometry on show
            self.restoreWidgetPosition()
        self.__was_restored = True

    def wheelEvent(self, event):
        """ Silently accept the wheel event. This is to ensure combo boxes
        and other controls that have focus don't receive this event unless
        the cursor is over them.
        """
        event.accept()

    def setCaption(self, caption):
        # we have to save caption title in case progressbar will change it
        self.captionTitle = str(caption)
        self.setWindowTitle(caption)

    # put this widget on top of all windows
    def reshow(self):
        self.show()
        self.raise_()
        self.activateWindow()

    def send(self, signalName, value, id=None):
        if not any(s.name == signalName for s in self.outputs):
            raise ValueError(
                '{} is not a valid output signal for widget {}'.format(
                    signalName, self.name))
        if self.signalManager is not None:
            self.signalManager.send(self, signalName, value, id)

    def __setattr__(self, name, value):
        """Set value to members of this instance or any of its members.

        If member is used in a gui control, notify the control about the change.

        name: name of the member, dot is used for nesting ("graph.point.size").
        value: value to set to the member.

        """

        names = name.rsplit(".")
        field_name = names.pop()
        obj = reduce(lambda o, n: getattr(o, n, None), names, self)
        if obj is None:
            raise AttributeError("Cannot set '{}' to {} ".format(name, value))

        if obj is self:
            super().__setattr__(field_name, value)
        else:
            setattr(obj, field_name, value)

        notify_changed(obj, field_name, value)

        if self.settingsHandler:
            self.settingsHandler.fast_save(self, name, value)

    def openContext(self, *a):
        self.settingsHandler.open_context(self, *a)

    def closeContext(self):
        self.settingsHandler.close_context(self)

    def retrieveSpecificSettings(self):
        pass

    def storeSpecificSettings(self):
        pass

    def saveSettings(self):
        self.settingsHandler.update_defaults(self)

    # this function is only intended for derived classes to send appropriate
    # signals when all settings are loaded
    def activate_loaded_settings(self):
        pass

    # reimplemented in other widgets
    def onDeleteWidget(self):
        pass

    def handleNewSignals(self):
        # this is called after all new signals have been handled
        # implement this in your widget if you want to process something only
        # after you received multiple signals
        pass

    # ############################################
    # PROGRESS BAR FUNCTIONS

    def progressBarInit(self, processEvents=QEventLoop.AllEvents):
        """
        Initialize the widget's progress (i.e show and set progress to 0%).

        .. note::
            This method will by default call `QApplication.processEvents`
            with `processEvents`. To suppress this behavior pass
            ``processEvents=None``.

        :param processEvents: Process events flag
        :type processEvents: `QEventLoop.ProcessEventsFlags` or `None`
        """
        self.startTime = time.time()
        self.setWindowTitle(self.captionTitle + " (0% complete)")

        if self.__progressState != 1:
            self.__progressState = 1
            self.processingStateChanged.emit(1)

        self.progressBarSet(0, processEvents)

    def progressBarSet(self, value, processEvents=QEventLoop.AllEvents):
        """
        Set the current progress bar to `value`.

        .. note::
            This method will by default call `QApplication.processEvents`
            with `processEvents`. To suppress this behavior pass
            ``processEvents=None``.

        :param float value: Progress value
        :param processEvents: Process events flag
        :type processEvents: `QEventLoop.ProcessEventsFlags` or `None`
        """
        old = self.__progressBarValue
        self.__progressBarValue = value

        if value > 0:
            if self.__progressState != 1:
                warnings.warn(
                    "progressBarSet() called without a "
                    "preceding progressBarInit()",
                    stacklevel=2)
                self.__progressState = 1
                self.processingStateChanged.emit(1)

            usedTime = max(1, time.time() - self.startTime)
            totalTime = (100.0 * usedTime) / float(value)
            remainingTime = max(0, totalTime - usedTime)
            h = int(remainingTime / 3600)
            min = int((remainingTime - h * 3600) / 60)
            sec = int(remainingTime - h * 3600 - min * 60)
            if h > 0:
                text = "%(h)d:%(min)02d:%(sec)02d" % vars()
            else:
                text = "%(min)d:%(sec)02d" % vars()
            self.setWindowTitle(
                self.captionTitle +
                " (%(value).2f%% complete, remaining time: %(text)s)" % vars())
        else:
            self.setWindowTitle(self.captionTitle + " (0% complete)")

        if old != value:
            self.progressBarValueChanged.emit(value)

        if processEvents is not None and processEvents is not False:
            qApp.processEvents(processEvents)

    def progressBarValue(self):
        return self.__progressBarValue

    progressBarValue = pyqtProperty(float,
                                    fset=progressBarSet,
                                    fget=progressBarValue)

    processingState = pyqtProperty(int, fget=lambda self: self.__progressState)

    def progressBarAdvance(self, value, processEvents=QEventLoop.AllEvents):
        self.progressBarSet(self.progressBarValue + value, processEvents)

    def progressBarFinished(self, processEvents=QEventLoop.AllEvents):
        """
        Stop the widget's progress (i.e hide the progress bar).

        .. note::
            This method will by default call `QApplication.processEvents`
            with `processEvents`. To suppress this behavior pass
            ``processEvents=None``.

        :param processEvents: Process events flag
        :type processEvents: `QEventLoop.ProcessEventsFlags` or `None`
        """
        self.setWindowTitle(self.captionTitle)
        if self.__progressState != 0:
            self.__progressState = 0
            self.processingStateChanged.emit(0)

        if processEvents is not None and processEvents is not False:
            qApp.processEvents(processEvents)

    #: Widget's status message has changed.
    statusMessageChanged = Signal(str)

    def setStatusMessage(self, text):
        if self.__statusMessage != text:
            self.__statusMessage = text
            self.statusMessageChanged.emit(text)

    def statusMessage(self):
        return self.__statusMessage

    def keyPressEvent(self, e):
        if (int(e.modifiers()), e.key()) in OWWidget.defaultKeyActions:
            OWWidget.defaultKeyActions[int(e.modifiers()), e.key()](self)
        else:
            QDialog.keyPressEvent(self, e)

    def information(self, id=0, text=None):
        self.setState("Info", id, text)

    def warning(self, id=0, text=""):
        self.setState("Warning", id, text)

    def error(self, id=0, text=""):
        self.setState("Error", id, text)

    def setState(self, state_type, id, text):
        changed = 0
        if type(id) == list:
            for val in id:
                if val in self.widgetState[state_type]:
                    self.widgetState[state_type].pop(val)
                    changed = 1
        else:
            if type(id) == str:
                text = id
                id = 0
            if not text:
                if id in self.widgetState[state_type]:
                    self.widgetState[state_type].pop(id)
                    changed = 1
            else:
                self.widgetState[state_type][id] = text
                changed = 1

        if changed:
            if type(id) == list:
                for i in id:
                    self.widgetStateChanged.emit(state_type, i, "")
            else:
                self.widgetStateChanged.emit(state_type, id, text or "")

        tooltip_lines = []
        highest_type = None
        for a_type in ("Error", "Warning", "Info"):
            msgs_for_ids = self.widgetState.get(a_type)
            if not msgs_for_ids:
                continue
            msgs_for_ids = list(msgs_for_ids.values())
            if not msgs_for_ids:
                continue
            tooltip_lines += msgs_for_ids
            if highest_type is None:
                highest_type = a_type

        if highest_type is None:
            self.set_warning_bar(None)
        elif len(tooltip_lines) == 1:
            msg = tooltip_lines[0]
            if "\n" in msg:
                self.set_warning_bar(highest_type,
                                     msg[:msg.index("\n")] + " (...)", msg)
            else:
                self.set_warning_bar(highest_type, tooltip_lines[0],
                                     tooltip_lines[0])
        else:
            self.set_warning_bar(
                highest_type,
                "{} problems during execution".format(len(tooltip_lines)),
                "\n".join(tooltip_lines))

        return changed

    def set_warning_bar(self, state_type, text=None, tooltip=None):
        colors = {
            "Error": ("#ffc6c6", "black", QStyle.SP_MessageBoxCritical),
            "Warning": ("#ffffc9", "black", QStyle.SP_MessageBoxWarning),
            "Info": ("#ceceff", "black", QStyle.SP_MessageBoxInformation)
        }
        current_height = self.height()
        if state_type is None:
            if not self.warning_bar.isHidden():
                new_height = current_height - self.warning_bar.height()
                self.warning_bar.setVisible(False)
                self.resize(self.width(), new_height)
            return
        background, foreground, icon = colors[state_type]
        style = QApplication.instance().style()
        self.warning_icon.setPixmap(style.standardIcon(icon).pixmap(14, 14))

        self.warning_bar.setStyleSheet(
            "background-color: {}; color: {};"
            "padding: 3px; padding-left: 6px; vertical-align: center".format(
                background, foreground))
        self.warning_label.setText(text)
        self.warning_bar.setToolTip(tooltip)
        if self.warning_bar.isHidden():
            self.warning_bar.setVisible(True)
            new_height = current_height + self.warning_bar.height()
            self.resize(self.width(), new_height)

    def widgetStateToHtml(self, info=True, warning=True, error=True):
        pixmaps = self.getWidgetStateIcons()
        items = []
        iconPath = {
            "Info": "canvasIcons:information.png",
            "Warning": "canvasIcons:warning.png",
            "Error": "canvasIcons:error.png"
        }
        for show, what in [(info, "Info"), (warning, "Warning"),
                           (error, "Error")]:
            if show and self.widgetState[what]:
                items.append('<img src="%s" style="float: left;"> %s' %
                             (iconPath[what], "\n".join(
                                 self.widgetState[what].values())))
        return "<br>".join(items)

    @classmethod
    def getWidgetStateIcons(cls):
        if not hasattr(cls, "_cached__widget_state_icons"):
            iconsDir = os.path.join(environ.canvas_install_dir, "icons")
            QDir.addSearchPath(
                "canvasIcons",
                os.path.join(environ.canvas_install_dir, "icons/"))
            info = QPixmap("canvasIcons:information.png")
            warning = QPixmap("canvasIcons:warning.png")
            error = QPixmap("canvasIcons:error.png")
            cls._cached__widget_state_icons = \
                {"Info": info, "Warning": warning, "Error": error}
        return cls._cached__widget_state_icons

    defaultKeyActions = {}

    if sys.platform == "darwin":
        defaultKeyActions = {
            (Qt.ControlModifier, Qt.Key_M):
            lambda self: self.showMaximized
            if self.isMinimized() else self.showMinimized(),
            (Qt.ControlModifier, Qt.Key_W):
            lambda self: self.setVisible(not self.isVisible())
        }

    def setBlocking(self, state=True):
        """ Set blocking flag for this widget. While this flag is set this
        widget and all its descendants will not receive any new signals from
        the signal manager
        """
        if self.__blocking != state:
            self.__blocking = state
            self.blockingStateChanged.emit(state)

    def isBlocking(self):
        """ Is this widget blocking signal processing.
        """
        return self.__blocking

    def resetSettings(self):
        self.settingsHandler.reset_settings(self)
class MainWindow(QWidget):
    progress = pyqtSignal(int)
    status = pyqtSignal(str)
    """Main window of the MTurKClient application"""
    def __init__(self, projFile):
        QWidget.__init__(self)
        self.projPath = os.path.split(projFile)[0]
        self.projName = os.path.split(projFile)[1]
        self.setFixedSize(500, 680)
        self.setWindowIcon(QIcon('icon.png'))
        self.setWindowIconText("MTurk Client")
        if os.path.exists(os.path.join(self.projPath, 'mturk_segmentation.ini')):
            self.task = SegmentationTask(projFile)
            self.segmentation_mode = True
        elif os.path.exists(os.path.join(self.projPath, 'mturk_features.ini')):
            self.task = CorrespondenceTask(projFile)
            self.segmentation_mode = False
        else:
            raise Exception('No configuration file found!')
        self.task.setParent(self)
        self.setWindowFlags(Qt.WindowCloseButtonHint)
        self.setTitle()

        ###Tab widget###
        self.tabWidget = QTabWidget()
        self.initUploadTab()
        self.initDownloadTab()
        self.initManageTab()
        self.initSettingTab()
        self.initStatusBar()

        # Layout management
        vbox = QVBoxLayout()
        vbox.addWidget(self.tabWidget)
        vbox.addWidget(self.statusBar)
        self.setLayout(vbox)
        self.show()

        self.task.loadVideoLabelFile()
        if not self.task.connect():
            self.status.emit("MTurk connection failed.")
        else:
            self.getBalance()

    def setTitle(self):
        if self.task.sandbox:
            self.setWindowTitle("MTurk Client - Sandbox Mode")
        else:
            self.setWindowTitle("MTurk Client")

    def getTotalNumberOfHITs(self):
        if self.segmentation_mode:
            return len(self.task.videoLabelHandler.objects) * int(self.task.assignments)
        else:
            if self.tabWidget.widget(0).findChildren(QCheckBox)[0].isChecked():
                shift = 25
            else:
                shift = 50
            xN = len(range(0, self.task.videoLabelHandler.imageWidth - shift, shift))
            yN = len(range(0, self.task.videoLabelHandler.imageHeight - shift, shift))
            return xN * yN * int(self.task.assignments)

    def getBalance(self):
        """Get current account balance and compute costs"""
        self.balance = self.task.connection.get_account_balance()[0]
        self.credit_label.setText("Your current account balance is:\t\t\t{0}".format(self.balance))

        costs = self.task.reward * self.getTotalNumberOfHITs()
        self.costLabel.setText("Costs per frame:\t\t\t\t\t${0}".format(costs))

    def updateTable(self):
        appDict, rejDict = self.task.reviewTool.updateTable()

        for i in range(self.table_turk.rowCount()):
            # Get workerID
            workerID = str(self.table_turk.item(i, 0).text())

            # Set rejected or approved
            if workerID in rejDict.keys():
                self.table_turk.item(i, 2).setText(str(rejDict[workerID]))
            if workerID in appDict.keys():
                self.table_turk.item(i, 3).setText(str(appDict[workerID]))

    def getStatus(self):
        """
        Get current status of the HITs that are being worked on and current account balance.
        """
        # Get Status as dictionary {WorkerID:23; ...}
        hitStatus, assignments = self.task.status()
        totalAssignments = self.getTotalNumberOfHITs()
        self.status.emit("Finished HITs: ({0}/{1})".format(assignments, totalAssignments))

        # Update Table
        for i, entry in enumerate(hitStatus):
            self.table_turk.insertRow(i)
            turker = QTableWidgetItem(entry[0])
            assignments = QTableWidgetItem(str(entry[1]))
            rejected = QTableWidgetItem(str(0))
            approved = QTableWidgetItem(str(0))

            self.table_turk.setItem(i, 0, turker)
            self.table_turk.setItem(i, 1, assignments)
            self.table_turk.setItem(i, 2, rejected)
            self.table_turk.setItem(i, 3, approved)

    def initSettingTab(self):
        # ##Setting Tab###
        setting_tab = QWidget()
        setting_tab_layout = QVBoxLayout()
        self.tabWidget.addTab(setting_tab, "Settings")

        # Task Box
        task_box = QGroupBox()
        task_box.setTitle(QString("Task properties"))
        task_layout = QGridLayout()

        # Name
        name = QLabel("Name:")
        name_value = QLineEdit() 
        name_value.setText(self.task.hittypename)
        name_value.setEnabled(False)
        clickable(name_value).connect(self.enable)
        task_layout.addWidget(name, 0, 1)
        task_layout.addWidget(name_value, 0, 2, 1, 3)

        # Description
        description = QLabel("Description:")
        description_value = QLineEdit() 
        description_value.setText(self.task.description)
        description_value.setEnabled(False)
        clickable(description_value).connect(self.enable)
        task_layout.addWidget(description, 1, 1)
        task_layout.addWidget(description_value, 1, 2, 1, 3)

        # Keywords
        keywords = QLabel("Keywords:")
        keywords_value = QLineEdit()
        keywords_value.setText(','.join(self.task.keywords))
        keywords_value.setEnabled(False)
        clickable(keywords_value).connect(self.enable)
        task_layout.addWidget(keywords, 2, 1)
        task_layout.addWidget(keywords_value, 2, 2, 1, 3)

        # Qualification
        qualification = QLabel("Qualification [%]:")
        qualification_value = QSpinBox()
        qualification_value.setSuffix('%')
        qualification_value.setValue(int(self.task.qualification))
        qualification_value.setEnabled(False)
        clickable(qualification_value).connect(self.enable)
        task_layout.addWidget(qualification, 3, 1)
        task_layout.addWidget(qualification_value, 3, 4)

        # Assignments
        assignments = QLabel("Assignments:")
        assignments_value = QSpinBox()
        assignments_value.setSuffix('')
        assignments_value.setValue(int(self.task.assignments))
        assignments_value.setEnabled(False)
        clickable(assignments_value).connect(self.enable)
        task_layout.addWidget(assignments, 4, 1)
        task_layout.addWidget(assignments_value, 4, 4)

        # Duration
        duration = QLabel("Duration [min]:") 
        duration_value = QSpinBox()
        duration_value.setSuffix('min')
        duration_value.setValue(int(self.task.duration))
        duration_value.setEnabled(False)
        clickable(duration_value).connect(self.enable)
        task_layout.addWidget(duration, 5, 1)
        task_layout.addWidget(duration_value, 5, 4)

        # Reward
        reward = QLabel("Reward [0.01$]:")
        reward_value = QDoubleSpinBox()
        reward_value.setRange(0.01, 0.5)
        reward_value.setSingleStep(0.01)
        reward_value.setSuffix('$')
        reward_value.setValue(self.task.reward)
        reward_value.setEnabled(False)
        clickable(reward_value).connect(self.enable)
        task_layout.addWidget(reward, 6, 1)
        task_layout.addWidget(reward_value, 6, 4)

        # Lifetime
        lifetime = QLabel("Lifetime [d]:")
        lifetime_value = QSpinBox()
        lifetime_value.setSuffix('d')
        lifetime_value.setValue(self.task.lifetime)
        lifetime_value.setEnabled(False)
        clickable(lifetime_value).connect(self.enable)
        task_layout.addWidget(lifetime, 7, 1)
        task_layout.addWidget(lifetime_value, 7, 4)

        # sandbox
        sandbox = QCheckBox("Sandbox")
        sandbox.setChecked(self.task.sandbox)
        task_layout.addWidget(sandbox, 8, 1)
        task_box.setLayout(task_layout)
        task_layout.setColumnMinimumWidth(1, 120)

        # Image Storage Box
        storage_box = QGroupBox()
        storage_box.setTitle(QString("Image Storage"))
        storage_layout = QGridLayout()

        # Host URL
        host_url = QLabel("Host-URL:")
        host_url_value = QLineEdit()
        host_url_value.setText(self.task.host_url)
        host_url_value.setEnabled(False)
        clickable(host_url_value).connect(self.enable)

        # Dropbox Path
        dropbox_path = QLabel("Dropbox-Path:")
        dropbox_path_value = QLineEdit()
        dropbox_path_value.setText(self.task.dropbox_path)
        dropbox_path_value.setEnabled(False)
        clickable(dropbox_path_value).connect(self.enable)

        # Dropbox or S3
        usingS3 = QRadioButton("S3")
        usingS3.setChecked(self.task.usingS3)
        usingS3.setEnabled(False)
        usingDropbox = QRadioButton("Dropbox")
        usingDropbox.setChecked(self.task.usingDropbox)

        storage_layout.addWidget(host_url, 0, 1)
        storage_layout.addWidget(host_url_value, 0, 2, 1, 3)
        storage_layout.addWidget(dropbox_path, 1, 1)
        storage_layout.addWidget(dropbox_path_value, 1, 2, 1, 3)

        # Add Layouts
        save_button = QPushButton("Save Settings")
        setting_tab_layout.addWidget(task_box)
        setting_tab_layout.addWidget(storage_box)
        setting_tab.setLayout(setting_tab_layout)
        save_button.clicked.connect(self.SaveSettings)

        storage_layout.addWidget(usingS3, 2, 1)
        storage_layout.addWidget(usingDropbox, 3, 1)
        storage_layout.addWidget(save_button, 3, 4)

        # storage_layout.addStretch(1)
        storage_box.setLayout(storage_layout)

    def initListView(self):
        """Init status table"""
        # List Box model
        model = QStandardItemModel()

        # Init list objects
        for i, frame in enumerate(self.task.videoLabelHandler.files):
            item = QStandardItem(frame + "\t{0} Objects".format(len(self.task.videoLabelHandler.objects)))
            item.setCheckState(Qt.Checked)
            item.setCheckable(True)
            model.appendRow(item)

        if self.segmentation_mode:
            model.item(0).setEnabled(False)
        else:
            model.item(i).setCheckState(Qt.Unchecked)
            model.item(i).setEnabled(False)

        # Set model
        self.view.setModel(model)

    def initUploadTab(self):
        ###Upload Tab###
        upload_tab = QWidget()
        upload_tab_layout = QVBoxLayout()
        self.tabWidget.addTab(upload_tab, "Upload HITs")

        # Frames Box
        frames_box = QGroupBox()
        frames_box.setTitle("Frame selection")
        frames_layout = QVBoxLayout()

        frames_label = QLabel("Select which frames to upload:")
        frames_layout.addWidget(frames_label)

        # Init list view
        self.view = QListView()
        frames_layout.addWidget(self.view)
        upload_button = QPushButton("Upload HITs")
        upload_button.clicked.connect(self.upload)

        frames_layout.addWidget(upload_button)
        frames_box.setLayout(frames_layout)

        # MotionOptions Box
        motionOptionsBox = QGroupBox()
        motionOptionsBox.setTitle("Motion Annotation Options")
        patchLabel = QLabel("Patch size: 50x50 Pixels")
        motionOptionsBoxLayout = QHBoxLayout()
        overlapping = QCheckBox("Overlapping Patches")
        overlapping.clicked.connect(self.getBalance)
        motionOptionsBoxLayout.addWidget(overlapping)
        motionOptionsBoxLayout.addWidget(patchLabel)
        motionOptionsBox.setLayout(motionOptionsBoxLayout)

        # LayerOptions Box
        options_box = QGroupBox()
        options_box.setTitle('Layer Annotation Options')
        blurLabel = QLabel("Amount: 4 Pixels")
        options_box_layout = QHBoxLayout()
        blur = QCheckBox("Blur Outlines")
        options_box_layout.addWidget(blur)
        options_box_layout.addWidget(blurLabel)
        options_box.setLayout(options_box_layout)

        # Disable not needed options
        if self.segmentation_mode:
            motionOptionsBox.setEnabled(False)
        else:
            options_box.setEnabled(False)

        # Costs
        costs_box = QGroupBox()
        costs_box.setTitle('Costs')
        costs_box_layout = QVBoxLayout()
        self.credit_label = QLabel("Your current account balance is:")
        self.costLabel = QLabel("Costs per frame:")
        costs_box_layout.addWidget(self.credit_label)
        costs_box_layout.addWidget(self.costLabel)
        costs_box.setLayout(costs_box_layout)

        # Upload Box
        upload_tab_layout.addWidget(frames_box)
        upload_tab_layout.addWidget(motionOptionsBox)
        upload_tab_layout.addWidget(options_box)
        upload_tab_layout.addWidget(costs_box)
        upload_tab.setLayout(upload_tab_layout)

    def initStatusBar(self):
        """Init status bar"""
        # Status bar
        self.progress.connect(self.updateProgressBar)
        self.status.connect(self.updateStatusBar)
        self.statusBar = QStatusBar()
        progress = QProgressBar()
        self.statusBar.addPermanentWidget(progress)

    def initDownloadTab(self):
        # # # Download Tab# # # 
        download_tab = QWidget()
        download_tab_layout = QVBoxLayout()
        self.tabWidget.addTab(download_tab, "Download HITs")

        # Status
        status_box = QGroupBox()
        status_box.setTitle("Status")
        status_layout = QGridLayout()
        self.table_turk = ContextTable(0, 4, self)
        self.table_turk.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.table_turk.setColumnWidth(0, 160)
        self.table_turk.setColumnWidth(1, 50)
        self.table_turk.setColumnWidth(2, 90)
        self.table_turk.setColumnWidth(3, 90)
        # self.table_turk.verticalHeader().setVisible(False)

        # Set Headers
        header_0 = QTableWidgetItem()
        header_0.setText("Turker")
        self.table_turk.setHorizontalHeaderItem(0, header_0)

        header_1 = QTableWidgetItem()
        header_1.setText("HITs")
        self.table_turk.setHorizontalHeaderItem(1, header_1)

        header_2 = QTableWidgetItem()
        header_2.setText("Rejected")
        self.table_turk.setHorizontalHeaderItem(2, header_2)

        header_3 = QTableWidgetItem()
        header_3.setText("Approved")
        self.table_turk.setHorizontalHeaderItem(3, header_3)

        status_layout.addWidget(self.table_turk, 0, 0, 1, 2)

        # Status Button
        status_button = QPushButton('Update Status')
        status_button.clicked.connect(self.getStatus)

        status_layout.addWidget(status_button, 1, 1)
        status_box.setLayout(status_layout)
        download_tab_layout.addWidget(status_box) 

        # Download Button
        download_button = QPushButton("Download Results")
        download_button.clicked.connect(self.download)
        status_layout.addWidget(download_button, 1, 0)

        # Options Box
        options_box = QGroupBox()
        options_box.setTitle("Import results")
        options_box_layout = QGridLayout()
        matching = QRadioButton("Choose best matching Outlines")
        matching.setEnabled(False)
        review = QRadioButton("Review by hand")
        review.setChecked(True)
        review_button = QPushButton("Review Results")
        review_button.clicked.connect(self.review)

        # Import Button
        import_button = QPushButton("Import results")
        import_button.clicked.connect(self.importResults)

        options_box_layout.addWidget(review, 0, 0)
        options_box_layout.addWidget(review_button, 0, 1)
        options_box_layout.addWidget(matching, 1, 0)
        options_box_layout.addWidget(import_button, 2, 0, 1, 2)

        options_box.setLayout(options_box_layout)
        download_tab_layout.addWidget(options_box)
        download_tab.setLayout(download_tab_layout)

    def initManageTab(self):
        ###Manage Tab###
        manage_tab = QWidget()
        manage_tab_layout = QVBoxLayout()
        self.tabWidget.addTab(manage_tab, "Manage HITs")

        # Send Box
        send_box_layout = QVBoxLayout()
        subject = QLineEdit()
        subject_label = QLabel("Subject:")

        send_text = QTextEdit()
        send_button = QPushButton("Send Message")
        send_button.setMinimumWidth(135)

        send_button.clicked.connect(self.sendMessage)

        allTurkers = QRadioButton("Send message to all Turkers")
        allTurkers.setChecked(True)
        singleTurker = QRadioButton("Send message to single Turker")

        workerIDLabel = QLabel('Worker-ID:')
        workerID = QLineEdit()

        def checkState():
            # Set enabled if checked
            if allTurkers.isChecked():
                workerIDLabel.setEnabled(False)
                workerID.setEnabled(False)
            else:
                workerIDLabel.setEnabled(True)
                workerID.setEnabled(True)

        # Connect to check state
        allTurkers.clicked.connect(checkState)
        singleTurker.clicked.connect(checkState)
        checkState()

        # Choose if single or all turkers receive message
        chooseSendLayout = QHBoxLayout()
        chooseSendLayout.addWidget(singleTurker)
        chooseSendLayout.addWidget(workerIDLabel)
        chooseSendLayout.addWidget(workerID)

        # Send box layout
        send_box = QGroupBox()
        send_box_layout.addWidget(allTurkers)
        send_box_layout.addLayout(chooseSendLayout)
        send_box_layout.addWidget(subject_label)
        send_box_layout.addWidget(subject)
        send_box_layout.addWidget(send_text)
        send_box_layout.addWidget(send_button)
        send_box_layout.setAlignment(send_button, Qt.AlignRight)
        send_box.setTitle("Notify Workers")
        send_box.setLayout(send_box_layout)
        manage_tab_layout.addWidget(send_box)

        # Pay box
        payBox = QGroupBox()
        payBox.setTitle("Pay Workers")
        payBox_layout = QGridLayout()

        approveFeedbackLabel = QLabel("Approve Feedback:")
        approveFeedback = QTextEdit()
        approveFeedback.setText("Thank you for your work.")

        rejectFeedback = QTextEdit()
        rejectFeedback.setText("We are sorry, but we cannot accept your work because you did not follow the instructions or submitted careless work.")

        payBox_layout.addWidget(approveFeedbackLabel, 0, 0)
        payBox_layout.addWidget(approveFeedback , 1, 0, 1, 0)
        reject_label = QLabel("{0} HITs will be rejected".format(0))
        approve_label = QLabel("{0} HITs will be approved".format(0))
        pay_button = QPushButton("Pay Turkers")
        pay_button.clicked.connect(self.pay)

        payBox_layout.addWidget(reject_label, 2, 0)
        payBox_layout.addWidget(approve_label, 3, 0)
        payBox_layout.addWidget(pay_button, 4, 0)
        payBox.setLayout(payBox_layout)
        manage_tab_layout.addWidget(payBox)

        # Delete Box
        deleteBox = QGroupBox()
        deleteBox.setTitle("Clean up finished HITs")
        deleteBox_layout = QHBoxLayout()
        delete_label = QLabel("{0} HITs are finished and can be deleted".format(0))
        delete_button = QPushButton("Delete HITs")
        delete_button.clicked.connect(self.delete)
        deleteBox_layout.addWidget(delete_label)
        deleteBox_layout.addWidget(delete_button)
        deleteBox.setLayout(deleteBox_layout)
        manage_tab_layout.addWidget(deleteBox)

        # Evaluation Button
        evalButton = QPushButton("Evaluate")
        evalButton.clicked.connect(self.evaluate)
        manage_tab_layout.addWidget(evalButton)

        # Add layouts to tab
        manage_tab.setLayout(manage_tab_layout)

    def SaveSettings(self):
        """Save settings to config file"""
        # Line edits
        lineEdits = self.tabWidget.widget(3).findChildren(QLineEdit)
        self.task._conf.set('Task', 'name', lineEdits[0].text())
        self.task._conf.set('Task', 'Description', lineEdits[1].text())
        self.task._conf.set('Task', 'Keywords', lineEdits[2].text())
        self.task._conf.set('Image storage', 'host-url', lineEdits[8].text())
        self.task._conf.set('Image storage', 'dropbox-path', lineEdits[9].text())

        # Spin boxes
        spinBoxes = self.tabWidget.widget(3).findChildren(QSpinBox)
        self.task._conf.set('Task', 'assignments', spinBoxes[1].value())
        self.task._conf.set('Task', 'qualification', spinBoxes[0].value())
        self.task._conf.set('Task', 'duration', spinBoxes[2].value())
        self.task._conf.set('Task', 'lifetime', spinBoxes[3].value())
        self.task._conf.set('Task', 'reward', self.tabWidget.widget(3).findChild(QDoubleSpinBox).value())

        # Dropbox usage
        radioButtons = self.tabWidget.widget(3).findChildren(QRadioButton)
        self.task._conf.set('Task', 'usings3', radioButtons[0].isChecked())
        self.task._conf.set('Task', 'usingdropbox', radioButtons[1].isChecked())

        # Sandbox
        self.task._conf.set('Task', 'sandbox', self.tabWidget.widget(3).findChild(QCheckBox).isChecked())

        # Write config file
        self.task.saveConfigFile()

        # Disable objects
        for obj in lineEdits:
            obj.setEnabled(False)
        for obj in spinBoxes:
            obj.setEnabled(False)
        self.tabWidget.widget(3).findChild(QDoubleSpinBox).setEnabled(False)

        # Reload Config File
        self.task.loadConfigFile()
        self.task.connect()
        self.setTitle()
        self.getBalance()
        self.status.emit('Settings saved')

    def pay(self):
        self.status.emit("Paying turkers...")
        feedback = self.tabWidget.widget(2).findChildren(QTextEdit)[1].document()
        self.task.pay(feedback.toPlainText())
        self.status.emit("Done")

    def enable(self):
        """Does nothing. But is required for the clickable widget option for now. Yeah!!"""
        pass

    def review(self):
        self.task.reviewHITs()
        self.updateTable()

    def sendMessage(self):
        """Send message to turkers"""
        # Goes the message to all or a single turker?
        if self.tabWidget.widget(2).findChildren(QRadioButton)[1].isChecked():
            workerID = self.tabWidget.widget(2).findChildren(QLineEdit)[0].text()
            if workerID == "":
                self.status.emit('Please provide Worker-ID')
                return False
        else:
            workerID = ""

        # Get subject and message
        subject = self.tabWidget.widget(2).findChildren(QLineEdit)[1].text()
        message = self.tabWidget.widget(2).findChildren(QTextEdit)[0].document()
        self.task.sendMessage(subject, message.toPlainText(), workerID=workerID)
        return True

    def upload(self):
        """Upload HITs"""
        message_box = QMessageBox()
        reply = message_box.question(self, 'Upload HITs',
                "Are you sure you want to upload the HITs?", QMessageBox.Yes, QMessageBox.No)

        if reply == QMessageBox.Yes:
            if self.segmentation_mode:
                if self.tabWidget.widget(0).findChildren(QCheckBox)[1].isChecked():
                    self.task.videoLabelHandler.blurOutlines()
                self.task.upload()
            else:
                if self.tabWidget.widget(0).findChildren(QCheckBox)[0].isChecked():
                    overlapping = True
                else:
                    overlapping = False
                self.task.upload(overlapping)

    def updateProgressBar(self, value):
        self.statusBar.children()[2].setValue(value)

    def updateStatusBar(self, mesg):
        self.statusBar.showMessage(mesg)

    def importResults(self):
        self.task.getTurked()

    def delete(self):
        self.task.deleteHit()

    def download(self):
        self.task.harvest()

    def evaluate(self):
        """
        Evaluate additional data from MTurk.

        The following statistics are computed:
            * Working Time
            * Feedback
            * Hit statistics
            * Working time per worker
            * Worker statistics
        """
        evaluation = Evaluation(self.task)
        evaluation.workingTime()
        evaluation.extractFeedback()
        evaluation.HITStatistics()
        evaluation.workingTimePerWorker()
        evaluation.workerStatistics()
Exemple #56
0
 def message_end(self, message):
     if message == '':
         self.hide()
         QStatusBar.clearMessage(self)
         self._widgetStatus.show()
Exemple #57
0
class MainWindow(QMainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.dirty = False

        self.setObjectName("MainWindow")
        self.resize(800, 600)
        self.setWindowTitle("GA")  # TODO
        # TODO        app_icon = get_icon('OpenFisca22.png')
        #        self.setWindowIcon(app_icon)
        self.setLocale(QLocale(QLocale.French, QLocale.France))
        self.setDockOptions(QMainWindow.AllowNestedDocks
                            | QMainWindow.AllowTabbedDocks
                            | QMainWindow.AnimatedDocks)

        self.centralwidget = QWidget(self)
        self.gridLayout = QGridLayout(self.centralwidget)
        self.setCentralWidget(self.centralwidget)
        self.centralwidget.hide()

        self.statusbar = QStatusBar(self)
        self.statusbar.setObjectName("statusbar")
        self.setStatusBar(self.statusbar)

        # Showing splash screen
        pixmap = QPixmap(':/images/splash.png', 'png')
        self.splash = QSplashScreen(pixmap)
        font = self.splash.font()
        font.setPixelSize(10)
        self.splash.setFont(font)
        self.splash.show()
        self.splash.showMessage(
            "Initialisation...",
            Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute,
            QColor(Qt.black))
        #        if CONF.get('main', 'current_version', '') != __version__:
        #            CONF.set('main', 'current_version', __version__)
        # Execute here the actions to be performed only once after
        # each update (there is nothing there for now, but it could
        # be useful some day...

        self.start()

    def start(self, restart=False):
        '''
        Starts main process
        '''
        # Preferences
        self.general_prefs = [PathConfigPage]
        self.apply_settings()

        # Dockwidgets creation
        self.splash.showMessage(
            "Creating widgets...",
            Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute,
            QColor(Qt.black))

        self.create_dockwidgets()
        self.populate_mainwidow()

        #################################################################
        ## Menu initialization
        #################################################################
        self.splash.showMessage(
            "Creating menubar...",
            Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute,
            QColor(Qt.black))
        # Menu Fichier
        self.file_menu = self.menuBar().addMenu("Fichier")
        action_export_png = create_action(
            self, 'Exporter le graphique',
            icon='document-save png.png')  #, triggered = None)
        action_export_csv = create_action(
            self, 'Exporter la table',
            icon='document-save csv.png')  #, triggered = None)
        action_pref = create_action(self,
                                    u'Préférences',
                                    QKeySequence.Preferences,
                                    icon='preferences-desktop.png',
                                    triggered=self.edit_preferences)
        action_quit = create_action(self,
                                    'Quitter',
                                    QKeySequence.Quit,
                                    icon='process-stop.png',
                                    triggered=SLOT('close()'))

        file_actions = [
            action_export_png, action_export_csv, None, action_pref, None,
            action_quit
        ]
        add_actions(self.file_menu, file_actions)

        # Menu Edit
        self.edit_menu = self.menuBar().addMenu(u"Édition")
        action_copy = create_action(self,
                                    'Copier',
                                    QKeySequence.Copy,
                                    triggered=self.global_callback,
                                    data='copy')

        edit_actions = [None, action_copy]
        add_actions(self.edit_menu, edit_actions)

        # Menu Projection
        self.projection_menu = self.menuBar().addMenu(u"Projection")
        #
        self.action_refresh_project_population = create_action(
            self,
            u'Calculer les projections de population',
            shortcut='F9',
            icon='calculator_green.png',
            triggered=self.project_population)

        projection_actions = [self.action_refresh_project_population, None]
        add_actions(self.projection_menu, projection_actions)

        # Menu Help
        help_menu = self.menuBar().addMenu("&Aide")
        action_about = create_action(self,
                                     u"&About GA",
                                     triggered=self.helpAbout)
        action_help = create_action(self,
                                    "&Aide",
                                    QKeySequence.HelpContents,
                                    triggered=self.helpHelp)
        help_actions = [action_about, action_help]
        add_actions(help_menu, help_actions)

        # Display Menu
        view_menu = self.createPopupMenu()
        view_menu.setTitle("&Affichage")
        self.menuBar().insertMenu(help_menu.menuAction(), view_menu)

        # Toolbar
        self.main_toolbar = self.create_toolbar(u"Barre d'outil",
                                                'main_toolbar')
        toolbar_actions = [
            action_export_png,
            action_export_csv,
            None,
            self.action_refresh_project_population,
        ]
        add_actions(self.main_toolbar, toolbar_actions)

        # Window settings
        self.splash.showMessage(
            "Restoring settings...",
            Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute,
            QColor(Qt.black))
        settings = QSettings()
        size = settings.value('MainWindow/Size',
                              QVariant(QSize(800, 600))).toSize()
        self.resize(size)
        position = settings.value('MainWindow/Position',
                                  QVariant(QPoint(0, 0))).toPoint()
        self.move(position)
        self.restoreState(settings.value("MainWindow/State").toByteArray())

        # Connectors

        self.connect(self._param_widget, SIGNAL('population_changed()'),
                     self.refresh_population)
        #        self.connect(self._param_widget, SIGNAL('rates_changed()'), self.refresh_cohorts)
        self.connect(self._param_widget, SIGNAL('state_proj_changed()'),
                     self.refresh_cohorts)

        self.refresh_population()
        self.load_data()

        self.splash.showMessage(
            "Loading survey data...",
            Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute,
            QColor(Qt.black))
        self.splash.hide()
        return

    def create_toolbar(self, title, object_name, iconsize=24):
        toolbar = self.addToolBar(title)
        toolbar.setObjectName(object_name)
        toolbar.setIconSize(QSize(iconsize, iconsize))
        return toolbar

    def create_dockwidgets(self):
        '''
        Creates dockwidgets
        '''
        self._population_widget = PopulationDataWidget(self)
        self._cohorts_widget = PopulationDataWidget(self)
        self._profiles_widget = ProfilesDataWidget(self)
        self._param_widget = ParametersWidget(self)
        self._plot_widget = PlotWidget(self)

        # TODO
        # plot population pyramides/expenses pyramides
        # générational flow

    def populate_mainwidow(self):
        '''
        Creates all dockwidgets
        '''
        left_widgets = [
            self._profiles_widget, self._population_widget,
            self._cohorts_widget, self._plot_widget
        ]
        first_left_widget = None
        for widget in left_widgets:
            self.addDockWidget(Qt.LeftDockWidgetArea, widget)
            if first_left_widget is None:
                first_left_widget = widget
            else:
                self.tabifyDockWidget(first_left_widget, widget)

    def global_callback(self):
        """Global callback"""
        widget = QApplication.focusWidget()
        action = self.sender()
        callback = unicode(action.data().toString())
        if hasattr(widget, callback):
            getattr(widget, callback)()

    def load_data(self):
        '''
        Loads population and profiles data 
        '''
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        try:
            profiles_file = CONF.get('paths', 'profiles_file')
            store = HDFStore(profiles_file, 'r')
            profiles = store['profiles']

        except Exception, e:
            self.population_loaded = False
            QMessageBox.warning(
                self, u"Impossible de lire les données de population",
                u"GA n'a pas réussi à lire les données de population. L'erreur suivante a été renvoyée:\n%s\n\nVous pouvez configuer le chemin vers le fichier de données  Fichier>Paramètres>Chemins>Fichier données population"
                % e)
            return False
        finally: