예제 #1
0
파일: qthelpers.py 프로젝트: jsantoul/ga
    def copy(self):
        '''
        Copy the table selection to the clipboard
        '''
        selection = self.selectionModel()
        indexes = selection.selectedIndexes()
        indexes.sort()
        previous = indexes.pop(0)
        data = self.model().data(previous)
        try:
            text = data.toString()
        except:
            text = str(data)
        selected_text = QString(text)

        for current in indexes:
            if current.row() != previous.row():
                selected_text.append('\n')
            else:
                selected_text.append('\t')
            data = self.model().data(current)
            try:
                text = data.toString()
            except:
                text = str(data)
            selected_text.append(text)
            previous = current
        selected_text.append('\n')
        QApplication.clipboard().setText(selected_text)
예제 #2
0
파일: qthelpers.py 프로젝트: jsantoul/ga
    def copy(self):
        '''
        Copy the table selection to the clipboard
        At this point, works only for single line selection
        '''
        selection = self.selectionModel()
        indexes = selection.selectedIndexes()
        indexes.sort()

        previous = indexes.pop(0)
        data = self.model().data(previous)
        text = data.toString()
        selected_text = QString(text)
        
        for current in indexes:
            if current.row() != previous.row():
                selected_text.append('\n')
            else:
                selected_text.append('\t')
            data = self.model().data(current)
            text = data.toString()
            selected_text.append(text)
            previous = current
        selected_text.append('\n')
        QApplication.clipboard().setText(selected_text)
예제 #3
0
파일: __init__.py 프로젝트: jsantoul/ga
 def ending_long_process(self, message=""):
     """
     Clearing main window's status bar
     and restoring mouse cursor
     """
     QApplication.restoreOverrideCursor()
     self.show_message(message, timeout=2000)
     QApplication.processEvents()
예제 #4
0
파일: __init__.py 프로젝트: jsantoul/ga
 def starting_long_process(self, message):
     """
     Showing message in main window's status bar
     and changing mouse cursor to Qt.WaitCursor
     """
     self.show_message(message)
     QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
     QApplication.processEvents()
예제 #5
0
def qapplication(translate=True):
    """Return QApplication instance
    Creates it if it doesn't already exist"""
    app = QApplication.instance()
    if not app:
        # Set Application name for Gnome 3
        # https://groups.google.com/forum/#!topic/pyside/24qxvwfrRDs
        app = QApplication(['OpenFisca'])
    if translate:
        install_translator(app)
    return app
예제 #6
0
파일: mixins.py 프로젝트: Pyke75/ga
 def mouseMoveEvent(self, event):
     """Show Pointing Hand Cursor on error messages"""
     text = self.get_line_at(event.pos())
     if get_error_match(text):
         if not self.__cursor_changed:
             QApplication.setOverrideCursor(QCursor(Qt.PointingHandCursor))
             self.__cursor_changed = True
         event.accept()
         return
     if self.__cursor_changed:
         QApplication.restoreOverrideCursor()
         self.__cursor_changed = False
     self.QT_CLASS.mouseMoveEvent(self, event)
예제 #7
0
파일: pydocgui.py 프로젝트: jsantoul/ga
 def initialize(self):
     """Start pydoc server and load home page"""
     QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
     QApplication.processEvents()
     self.start_server()
     self.go_home()
     QApplication.restoreOverrideCursor()
예제 #8
0
파일: pydocgui.py 프로젝트: jsantoul/ga
 def initialize(self):
     """Start pydoc server and load home page"""
     QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
     QApplication.processEvents()
     self.start_server()
     self.go_home()
     QApplication.restoreOverrideCursor()
예제 #9
0
파일: qthelpers.py 프로젝트: jsantoul/ga
from src.gui.qt.QtGui import (QDialog, QVBoxLayout)



class Form(QDialog):
    def __init__(self,parent=None):
        super(Form,self).__init__(parent)

        df = testDf() # make up some data
        widget = DataFrameWidget(df)
        widget.resizeColumnsToContents()

        layout = QVBoxLayout()
        layout.addWidget(widget)
        self.setLayout(layout)

if __name__=='__main__':
    import sys
    import numpy as np

    app = QApplication(sys.argv)
    form = Form()
    form.show()
    app.exec_()





예제 #10
0
파일: mixins.py 프로젝트: Pyke75/ga
 def leaveEvent(self, event):
     """If cursor has not been restored yet, do it now"""
     if self.__cursor_changed:
         QApplication.restoreOverrideCursor()
         self.__cursor_changed = False
     self.QT_CLASS.leaveEvent(self, event)
예제 #11
0
파일: base.py 프로젝트: Pyke75/ga
    def show_list(self, completion_list, automatic=True):
        if not self.show_single and len(completion_list) == 1 and not automatic:
            self.textedit.insert_completion(completion_list[0])
            return
        
        self.completion_list = completion_list
        self.clear()
        self.addItems(completion_list)
        self.setCurrentRow(0)
        
        QApplication.processEvents(QEventLoop.ExcludeUserInputEvents)
        self.show()
        self.setFocus()
        self.raise_()
        
        # Retrieving current screen height
        desktop = QApplication.desktop()
        srect = desktop.availableGeometry(desktop.screenNumber(self))
        screen_right = srect.right()
        screen_bottom = srect.bottom()
        
        point = self.textedit.cursorRect().bottomRight()
        point.setX(point.x()+self.textedit.get_linenumberarea_width())
        point = self.textedit.mapToGlobal(point)

        # Computing completion widget and its parent right positions
        comp_right = point.x()+self.width()
        ancestor = self.parent()
        if ancestor is None:
            anc_right = screen_right
        else:
            anc_right = min([ancestor.x()+ancestor.width(), screen_right])
        
        # Moving completion widget to the left
        # if there is not enough space to the right
        if comp_right > anc_right:
            point.setX(point.x()-self.width())
        
        # Computing completion widget and its parent bottom positions
        comp_bottom = point.y()+self.height()
        ancestor = self.parent()
        if ancestor is None:
            anc_bottom = screen_bottom
        else:
            anc_bottom = min([ancestor.y()+ancestor.height(), screen_bottom])
        
        # Moving completion widget above if there is not enough space below
        x_position = point.x()
        if comp_bottom > anc_bottom:
            point = self.textedit.cursorRect().topRight()
            point = self.textedit.mapToGlobal(point)
            point.setX(x_position)
            point.setY(point.y()-self.height())
            
        if ancestor is not None:
            # Useful only if we set parent to 'ancestor' in __init__
            point = ancestor.mapFromGlobal(point)
        self.move(point)
        
        if unicode(self.textedit.completion_text):
            # When initialized, if completion text is not empty, we need 
            # to update the displayed list:
            self.update_current()
예제 #12
0
파일: base.py 프로젝트: Pyke75/ga
 def copy(self):
     """
     Reimplement Qt method
     Copy text to clipboard with correct EOL chars
     """
     QApplication.clipboard().setText(self.get_selected_text())
예제 #13
0
파일: base.py 프로젝트: jsantoul/ga
 def paste(self):
     """Reimplement Qt method"""
     if self.has_selected_text():
         self.remove_selected_text()
     self.insert_text(QApplication.clipboard().text())
예제 #14
0
파일: base.py 프로젝트: jsantoul/ga
    def show_list(self, completion_list, automatic=True):
        if not self.show_single and len(
                completion_list) == 1 and not automatic:
            self.textedit.insert_completion(completion_list[0])
            return

        self.completion_list = completion_list
        self.clear()
        self.addItems(completion_list)
        self.setCurrentRow(0)

        QApplication.processEvents(QEventLoop.ExcludeUserInputEvents)
        self.show()
        self.setFocus()
        self.raise_()

        # Retrieving current screen height
        desktop = QApplication.desktop()
        srect = desktop.availableGeometry(desktop.screenNumber(self))
        screen_right = srect.right()
        screen_bottom = srect.bottom()

        point = self.textedit.cursorRect().bottomRight()
        point.setX(point.x() + self.textedit.get_linenumberarea_width())
        point = self.textedit.mapToGlobal(point)

        # Computing completion widget and its parent right positions
        comp_right = point.x() + self.width()
        ancestor = self.parent()
        if ancestor is None:
            anc_right = screen_right
        else:
            anc_right = min([ancestor.x() + ancestor.width(), screen_right])

        # Moving completion widget to the left
        # if there is not enough space to the right
        if comp_right > anc_right:
            point.setX(point.x() - self.width())

        # Computing completion widget and its parent bottom positions
        comp_bottom = point.y() + self.height()
        ancestor = self.parent()
        if ancestor is None:
            anc_bottom = screen_bottom
        else:
            anc_bottom = min([ancestor.y() + ancestor.height(), screen_bottom])

        # Moving completion widget above if there is not enough space below
        x_position = point.x()
        if comp_bottom > anc_bottom:
            point = self.textedit.cursorRect().topRight()
            point = self.textedit.mapToGlobal(point)
            point.setX(x_position)
            point.setY(point.y() - self.height())

        if ancestor is not None:
            # Useful only if we set parent to 'ancestor' in __init__
            point = ancestor.mapFromGlobal(point)
        self.move(point)

        if unicode(self.textedit.completion_text):
            # When initialized, if completion text is not empty, we need
            # to update the displayed list:
            self.update_current()
예제 #15
0
파일: base.py 프로젝트: jsantoul/ga
 def copy(self):
     """
     Reimplement Qt method
     Copy text to clipboard with correct EOL chars
     """
     QApplication.clipboard().setText(self.get_selected_text())
예제 #16
0
파일: Parameters.py 프로젝트: benjello/ga
            profiles = store_prof['profiles']
            
            self.set_population_prolong()
            self.set_taxes_proj()
            
        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:

            
            store_prof.close()
            self.update_population_choices()
            QApplication.restoreOverrideCursor()

        self._input_profiles = profiles.reset_index()
        
        
        
    def set_population(self):
        '''
        Sets population data
        '''
        widget = self.population_combo.box
        if isinstance(widget, QComboBox):
            data = widget.itemData(widget.currentIndex())                
            data_name = unicode(data.toString())
            self.population_name = data_name
            self.emit(SIGNAL('population_changed()'))
예제 #17
0
파일: base.py 프로젝트: Pyke75/ga
 def paste(self):
     """Reimplement Qt method"""
     if self.has_selected_text():
         self.remove_selected_text()
     self.insert_text(QApplication.clipboard().text())
예제 #18
0
            self.set_population_prolong()
            self.set_taxes_proj()

        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:

            store_prof.close()
            self.update_population_choices()
            QApplication.restoreOverrideCursor()

        self._input_profiles = profiles.reset_index()

    def set_population(self):
        '''
        Sets population data
        '''
        widget = self.population_combo.box
        if isinstance(widget, QComboBox):
            data = widget.itemData(widget.currentIndex())
            data_name = unicode(data.toString())
            self.population_name = data_name
            self.emit(SIGNAL('population_changed()'))

    def update_population_choices(self):