Exemple #1
0
def main():
    """Standard boilerplate Qt application code."""
    parser = argparse.ArgumentParser()
    parser.add_argument('filename', nargs='?', help='image or label filename')
    parser.add_argument('--output', '-O', '-o', help='output label name')
    parser.add_argument('--nodata', dest='store_data', action='store_false',
                        help='stop storing image data to JSON file')
    parser.add_argument('--labels', help='comma separated list of labels')
    parser.add_argument('--nosortlabels', dest='sort_labels',
                        action='store_false', help='stop sorting labels')
    args = parser.parse_args()

    if args.labels is not None:
        args.labels = args.labels.split(',')

    app = QApplication(sys.argv)
    app.setApplicationName(__appname__)
    app.setWindowIcon(newIcon("app"))
    win = MainWindow(
        filename=args.filename,
        output=args.output,
        store_data=args.store_data,
        labels=args.labels,
        sort_labels=args.sort_labels,
    )
    win.show()
    win.raise_()
    sys.exit(app.exec_())
Exemple #2
0
def main():
    """Standard boilerplate Qt application code."""
    parser = argparse.ArgumentParser()
    parser.add_argument('filename', nargs='?', help='image or label filename')
    parser.add_argument('--output', '-O', '-o', help='output label name')
    parser.add_argument('--nodata', dest='store_data', action='store_false',
                        help='stop storing image data to JSON file')
    parser.add_argument('--labels', help='comma separated list of labels')
    parser.add_argument('--nosortlabels', dest='sort_labels',
                        action='store_false', help='stop sorting labels')
    args = parser.parse_args()

    if args.labels is not None:
        args.labels = args.labels.split(',')

    app = QApplication(sys.argv)
    app.setApplicationName(__appname__)
    app.setWindowIcon(newIcon("app"))
    win = MainWindow(
        filename=args.filename,
        output=args.output,
        store_data=args.store_data,
        labels=args.labels,
        sort_labels=args.sort_labels,
    )
    win.show()
    win.raise_()
    sys.exit(app.exec_())
 def __init__(self,
              text="Enter object label",
              parent=None,
              labels=None,
              sort_labels=True,
              show_text_field=True):
     super(LabelDialog, self).__init__(parent)
     self.edit = LabelQLineEdit()
     self.edit.setPlaceholderText(text)
     self.edit.setValidator(labelValidator())
     self.edit.editingFinished.connect(self.postProcess)
     layout = QtWidgets.QVBoxLayout()
     if show_text_field:
         layout.addWidget(self.edit)
     # buttons
     self.buttonBox = bb = QtWidgets.QDialogButtonBox(
         QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel,
         QtCore.Qt.Horizontal,
         self,
     )
     bb.button(bb.Ok).setIcon(newIcon('done'))
     bb.button(bb.Cancel).setIcon(newIcon('undo'))
     bb.accepted.connect(self.validate)
     bb.rejected.connect(self.reject)
     layout.addWidget(bb)
     # label_list
     self.labelList = QtWidgets.QListWidget()
     self._sort_labels = sort_labels
     if labels:
         self.labelList.addItems(labels)
     if self._sort_labels:
         self.labelList.sortItems()
     else:
         self.labelList.setDragDropMode(
             QtGui.QAbstractItemView.InternalMove)
     self.labelList.currentItemChanged.connect(self.labelSelected)
     self.edit.setListWidget(self.labelList)
     layout.addWidget(self.labelList)
     self.setLayout(layout)
     # completion
     completer = QtWidgets.QCompleter()
     completer.setCompletionMode(QtWidgets.QCompleter.InlineCompletion)
     completer.setModel(self.labelList.model())
     self.edit.setCompleter(completer)
Exemple #4
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--version', '-V', action='store_true',
                        help='show version')
    parser.add_argument('filename', nargs='?', help='image or label filename')
    parser.add_argument('--output', '-O', '-o', help='output label name')
    parser.add_argument('--config', dest='config_file', help='config file')
    # config
    parser.add_argument('--nodata', dest='store_data', action='store_false',
                        help='stop storing image data to JSON file')
    parser.add_argument('--autosave', dest='auto_save', action='store_true',
                        help='auto save')
    parser.add_argument('--labels',
                        help='comma separated list of labels OR file '
                        'containing one label per line')
    parser.add_argument('--nosortlabels', dest='sort_labels',
                        action='store_false', help='stop sorting labels')
    parser.add_argument('--validatelabel', dest='validate_label',
                        choices=['exact', 'instance'],
                        help='label validation types')
    args = parser.parse_args()

    if args.version:
        print('{0} {1}'.format(__appname__, __version__))
        sys.exit(0)

    if args.labels is None:
        if args.validate_label is not None:
            logger.error('--labels must be specified with --validatelabel or '
                         'validate_label: true in the config file '
                         '(ex. ~/.labelmerc).')
            sys.exit(1)
    else:
        if os.path.isfile(args.labels):
            args.labels = [l.strip() for l in open(args.labels, 'r')
                           if l.strip()]
        else:
            args.labels = [l for l in args.labels.split(',') if l]

    config_from_args = args.__dict__
    config_from_args.pop('version')
    filename = config_from_args.pop('filename')
    output = config_from_args.pop('output')
    config_file = config_from_args.pop('config_file')
    config = get_config(config_from_args, config_file)

    app = QtWidgets.QApplication(sys.argv)
    app.setApplicationName(__appname__)
    app.setWindowIcon(newIcon('icon'))
    win = MainWindow(config=config, filename=filename, output=output)
    win.show()
    win.raise_()
    sys.exit(app.exec_())
Exemple #5
0
 def __init__(self, text="Enter object label", parent=None, labels=None,
              sort_labels=True, show_text_field=True):
     super(LabelDialog, self).__init__(parent)
     self.edit = LabelQLineEdit()
     self.edit.setPlaceholderText(text)
     self.edit.setValidator(labelValidator())
     self.edit.editingFinished.connect(self.postProcess)
     layout = QtWidgets.QVBoxLayout()
     if show_text_field:
         layout.addWidget(self.edit)
     # buttons
     self.buttonBox = bb = QtWidgets.QDialogButtonBox(
         QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel,
         QtCore.Qt.Horizontal,
         self,
     )
     bb.button(bb.Ok).setIcon(newIcon('done'))
     bb.button(bb.Cancel).setIcon(newIcon('undo'))
     bb.accepted.connect(self.validate)
     bb.rejected.connect(self.reject)
     layout.addWidget(bb)
     # label_list
     self.labelList = QtWidgets.QListWidget()
     self._sort_labels = sort_labels
     if labels:
         self.labelList.addItems(labels)
     if self._sort_labels:
         self.labelList.sortItems()
     else:
         self.labelList.setDragDropMode(
             QtGui.QAbstractItemView.InternalMove)
     self.labelList.currentItemChanged.connect(self.labelSelected)
     self.edit.setListWidget(self.labelList)
     layout.addWidget(self.labelList)
     self.setLayout(layout)
     # completion
     completer = QtWidgets.QCompleter()
     completer.setCompletionMode(QtWidgets.QCompleter.InlineCompletion)
     completer.setModel(self.labelList.model())
     self.edit.setCompleter(completer)
Exemple #6
0
 def __init__(self, text="Enter object label", parent=None, labels=None,
              sort_labels=True, show_text_field=True):
     super(LabelDialog, self).__init__(parent)
     self.parent = parent
     self.uuid = QtWidgets.QLabel('uuid')
     self.label = QtWidgets.QLabel('Label')            
     self.bnr_type = QtWidgets.QLabel('Type')
     self.cust_display_name = QtWidgets.QLabel('Customer Display Name')        
     self.pts_display = QtWidgets.QLabel('Points')
     self.uuid_edit = QtWidgets.QLineEdit()
     self.label_edit = QtWidgets.QLineEdit()
     self.bnr_type_edit = QtWidgets.QLineEdit()
     self.cust_display_name_edit = QtWidgets.QLineEdit()
     self.cust_display_name_edit.editingFinished.connect(self.postProcess)
     self.pts_display_edit = QtWidgets.QLineEdit()
     grid = QtWidgets.QGridLayout()
     grid.setSpacing(10)
     grid.addWidget(self.uuid, 1, 0)
     grid.addWidget(self.uuid_edit, 1, 1)
     grid.addWidget(self.label, 2, 0)
     grid.addWidget(self.label_edit, 2, 1)        
     grid.addWidget(self.bnr_type, 3, 0)
     grid.addWidget(self.bnr_type_edit, 3, 1)                
     grid.addWidget(self.cust_display_name, 4, 0)
     grid.addWidget(self.cust_display_name_edit, 4, 1)                
     grid.addWidget(self.pts_display, 5, 0)
     grid.addWidget(self.pts_display_edit, 5, 1)
     # buttons
     self.buttonBox = bb = QtWidgets.QDialogButtonBox(
         QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel,
         QtCore.Qt.Horizontal,
         self,
     )
     bb.button(bb.Ok).setIcon(newIcon('done'))
     bb.button(bb.Cancel).setIcon(newIcon('undo'))
     bb.accepted.connect(self.validate)
     bb.rejected.connect(self.reject)
     grid.addWidget(bb, 6,0)
     self.setLayout(grid)
     self.resize(QtCore.QSize(600,400))
Exemple #7
0
 def updateFileMenu(self):
     current = self.filename
     def exists(filename):
         return os.path.exists(str(filename))
     menu = self.menus.recentFiles
     menu.clear()
     files = [f for f in self.recentFiles if f != current and exists(f)]
     for i, f in enumerate(files):
         icon = newIcon('labels')
         action = QAction(
                 icon, '&%d %s' % (i+1, QFileInfo(f).fileName()), self)
         action.triggered.connect(partial(self.loadRecent, f))
         menu.addAction(action)
Exemple #8
0
 def updateFileMenu(self):
     current = self.filename
     def exists(filename):
         return os.path.exists(str(filename))
     menu = self.menus.recentFiles
     menu.clear()
     files = [f for f in self.recentFiles if f != current and exists(f)]
     for i, f in enumerate(files):
         icon = newIcon('labels')
         action = QAction(
                 icon, '&%d %s' % (i+1, QFileInfo(f).fileName()), self)
         action.triggered.connect(partial(self.loadRecent, f))
         menu.addAction(action)
Exemple #9
0
def main():
    """Standard boilerplate Qt application code."""
    parser = argparse.ArgumentParser()
    parser.add_argument('filename', nargs='?', help='image or label filename')
    parser.add_argument('--output', '-O', '-o', help='output label name')
    parser.add_argument('--nodata',
                        dest='store_data',
                        action='store_false',
                        help='stop storing image data to JSON file')
    parser.add_argument('--autosave', action='store_true', help='auto save')
    parser.add_argument('--labels',
                        help='comma separated list of labels OR file '
                        'containing one label per line')
    parser.add_argument('--nosortlabels',
                        dest='sort_labels',
                        action='store_false',
                        help='stop sorting labels')
    parser.add_argument('--validatelabel',
                        choices=['exact', 'instance'],
                        help='label validation types')
    args = parser.parse_args()

    if args.labels is None:
        if args.validatelabel is not None:
            logger.error('--labels must be specified with --validatelabel')
            sys.exit(1)
    else:
        if os.path.isfile(args.labels):
            args.labels = [
                l.strip() for l in open(args.labels, 'r') if l.strip()
            ]
        else:
            args.labels = [l for l in args.labels.split(',') if l]

    app = QtWidgets.QApplication(sys.argv)
    app.setApplicationName(__appname__)
    app.setWindowIcon(newIcon("icon"))
    win = MainWindow(
        filename=args.filename,
        output=args.output,
        store_data=args.store_data,
        labels=args.labels,
        sort_labels=args.sort_labels,
        auto_save=args.autosave,
        validate_label=args.validatelabel,
    )
    win.show()
    win.raise_()
    sys.exit(app.exec_())
Exemple #10
0
def main():
    """Standard boilerplate Qt application code."""
    parser = argparse.ArgumentParser()
    parser.add_argument('filename', nargs='?', help='image or label filename')
    parser.add_argument('--output', '-O', '-o', help='output label name')
    parser.add_argument('--nodata', dest='store_data', action='store_false',
                        help='Stop storing image data to JSON file.')
    args = parser.parse_args()

    app = QApplication(sys.argv)
    app.setApplicationName(__appname__)
    app.setWindowIcon(newIcon("app"))
    win = MainWindow(args.filename, args.output, args.store_data)
    win.show()
    win.raise_()
    sys.exit(app.exec_())
Exemple #11
0
def main():
    """Standard boilerplate Qt application code."""
    parser = argparse.ArgumentParser()
    parser.add_argument('filename', nargs='?', help='image or label filename')
    parser.add_argument('-O', '--output', help='output label name')
    args = parser.parse_args()

    filename = args.filename
    output = args.output

    app = QApplication(sys.argv)
    app.setApplicationName(__appname__)
    app.setWindowIcon(newIcon("app"))
    win = MainWindow(filename, output)
    win.show()
    win.raise_()
    sys.exit(app.exec_())
Exemple #12
0
def main():
    """Standard boilerplate Qt application code."""
    parser = argparse.ArgumentParser()
    parser.add_argument('filename', nargs='?', help='image or label filename')
    parser.add_argument('-O', '--output', help='output label name')
    args = parser.parse_args()

    filename = args.filename
    output = args.output

    app = QApplication(sys.argv)
    app.setApplicationName(__appname__)
    app.setWindowIcon(newIcon("app"))
    win = MainWindow(filename, output)
    win.show()
    win.raise_()
    sys.exit(app.exec_())
Exemple #13
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--version',
                        '-V',
                        action='store_true',
                        help='show version')
    parser.add_argument('filename', nargs='?', help='image or label filename')
    parser.add_argument('--output', '-O', '-o', help='output label name')
    parser.add_argument('--config', dest='config_file', help='config file')
    # config
    parser.add_argument('--nodata',
                        dest='store_data',
                        action='store_false',
                        help='stop storing image data to JSON file')
    parser.add_argument('--autosave',
                        dest='auto_save',
                        action='store_true',
                        help='auto save')
    parser.add_argument('--labels',
                        help='comma separated list of labels OR file '
                        'containing one label per line')
    parser.add_argument('--nosortlabels',
                        dest='sort_labels',
                        action='store_false',
                        help='stop sorting labels')
    parser.add_argument('--validatelabel',
                        dest='validate_label',
                        choices=['exact', 'instance'],
                        help='label validation types')
    args = parser.parse_args()

    if args.version:
        print('{0} {1}'.format(__appname__, __version__))
        sys.exit(0)

    if args.labels is None:
        if args.validate_label is not None:
            logger.error('--labels must be specified with --validatelabel or '
                         'validate_label: true in the config file '
                         '(ex. ~/.labelmerc).')
            sys.exit(1)
    else:
        if os.path.isfile(args.labels):
            with codecs.open(args.labels, 'r', encoding='utf-8') as f:
                args.labels = [l.strip() for l in f if l.strip()]
        else:
            args.labels = [l for l in args.labels.split(',') if l]

    config_from_args = args.__dict__
    config_from_args.pop('version')
    filename = config_from_args.pop('filename')
    output = config_from_args.pop('output')
    config_file = config_from_args.pop('config_file')
    # drop the default config
    if not config_from_args['auto_save']:
        config_from_args.pop('auto_save')
    if config_from_args['store_data']:
        config_from_args.pop('store_data')
    if not config_from_args['labels']:
        config_from_args.pop('labels')
    if not config_from_args['sort_labels']:
        config_from_args.pop('sort_labels')
    if not config_from_args['validate_label']:
        config_from_args.pop('validate_label')
    config = get_config(config_from_args, config_file)

    app = QtWidgets.QApplication(sys.argv)
    app.setApplicationName(__appname__)
    app.setWindowIcon(newIcon('icon'))
    win = MainWindow(config=config, filename=filename, output=output)
    win.show()
    win.raise_()
    sys.exit(app.exec_())
Exemple #14
0
    def __init__(
        self,
        parent=None,
    ):
        super(MetaDialog, self).__init__(parent)
        self.parent = parent
        self.setWindowTitle('Meta information')
        regex_rules = 'a-zA-Z0-9.,_ -#(){}'
        regex = QtCore.QRegExp('^[' + regex_rules + ']+$')
        self.street1 = QtWidgets.QLabel('street1')
        self.street2 = QtWidgets.QLabel('street2')
        self.city = QtWidgets.QLabel('City')
        self.state = QtWidgets.QLabel('State')
        self.country = QtWidgets.QLabel('Country')
        self.date_created = QtWidgets.QLabel('Date Created')
        self.lat_long = QtWidgets.QLabel('lat/long')
        self.cust_display_name = QtWidgets.QLabel('Customer display name')
        self.bnr_display_name = QtWidgets.QLabel('Bossanova internal name')
        self.uuid = QtWidgets.QLabel('UUID')
        self.calc_lat_long = QtWidgets.QPushButton('Calc')

        self.street1_edit = QtWidgets.QLineEdit()
        self.street2_edit = QtWidgets.QLineEdit()
        self.city_edit = QtWidgets.QLineEdit()
        self.state_edit = QtWidgets.QLineEdit()
        self.country_edit = QtWidgets.QLineEdit()
        self.lat_long_edit = QtWidgets.QLineEdit()
        self.date_created_edit = QtWidgets.QLineEdit()
        self.date_created_edit.setText(
            datetime.datetime.now().strftime('%Y-%m-%d'))
        self.date_created_edit.setReadOnly(True)
        self.cust_display_name_edit = QtWidgets.QLineEdit()
        self.bnr_display_name_edit = QtWidgets.QLineEdit()
        self.uuid_edit = QtWidgets.QLineEdit()
        self.uuid_edit.setText(getUUID())
        self.uuid_edit.setReadOnly(True)
        self.calc_lat_long.clicked.connect(self._calculate_lat_long)
        self.widgets = [
            self.street1_edit, self.street2_edit, self.city_edit,
            self.state_edit, self.country_edit, self.bnr_display_name_edit,
            self.cust_display_name_edit
        ]
        self._set_widget_tooltip_property(self.widgets, regex_rules)
        self._set_widget_edit_property(self.widgets, self.postProcess)
        self._set_widget_validators(self.widgets, regex)

        grid = QtWidgets.QGridLayout()
        grid.setSpacing(10)
        grid.addWidget(self.street1, 0, 0)
        grid.addWidget(self.street1_edit, 0, 1)
        grid.addWidget(self.street2, 1, 0)
        grid.addWidget(self.street2_edit, 1, 1)
        grid.addWidget(self.city, 2, 0)
        grid.addWidget(self.city_edit, 2, 1)
        grid.addWidget(self.state, 3, 0)
        grid.addWidget(self.state_edit, 3, 1)
        grid.addWidget(self.country, 5, 0)
        grid.addWidget(self.country_edit, 5, 1)
        grid.addWidget(self.date_created, 6, 0)
        grid.addWidget(self.date_created_edit, 6, 1)
        grid.addWidget(self.lat_long, 7, 0)
        grid.addWidget(self.lat_long_edit, 7, 1)
        grid.addWidget(self.calc_lat_long, 7, 2)
        grid.addWidget(self.cust_display_name, 8, 0)
        grid.addWidget(self.cust_display_name_edit, 8, 1)
        grid.addWidget(self.bnr_display_name, 9, 0)
        grid.addWidget(self.bnr_display_name_edit, 9, 1)
        grid.addWidget(self.uuid, 10, 0)
        grid.addWidget(self.uuid_edit, 10, 1)
        # buttons
        self.buttonBox = bb = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel,
            QtCore.Qt.Horizontal,
            self,
        )
        bb.button(bb.Ok).setIcon(newIcon('done'))
        bb.button(bb.Cancel).setIcon(newIcon('undo'))
        bb.accepted.connect(self.validate)
        bb.rejected.connect(self.reject)
        grid.addWidget(bb, 11, 0)
        self.setLayout(grid)