Create a qt.conf file next to the current executable
421834
def createqtconf():
    """"""

    template = """[Paths]
Prefix = {path}
Binaries = {path}
"""

    import PyQt5

    exedir = os.path.dirname(sys.executable)
    qtpath = os.path.join(exedir, "qt.conf")
    pyqt5path = os.path.abspath(PyQt5.__file__)
    binpath = os.path.dirname(pyqt5path).replace("\\", "/")

    try:
        with open(qtpath, "w") as f:
            f.write(template.format(path=binpath))
    except:
        pass
472026
def write_conf(self):
        
        f = open(self.output_filename, 'w')
        print(self.t.render(prefixes=self.prefixes), file=f)
        f.close()
969650
def generateUiClasses(srcpath):
    
    import_qt(globals())
    
    for root, folders, files in os.walk(srcpath):
        found = False
        for file in files:
            name, ext = os.path.splitext(file)
            if ext != '.ui':
                continue
            
            found = True
            
            wrapper = QT_WRAPPER.lower()
            basename = file.replace('.ui', '').replace('.', '_')
            filename = '{0}_{1}_ui.py'.format(basename, wrapper)
            
            outfile = os.path.join(root, filename)
            
            # compile the ui
            f = open(outfile, 'w')
            uic.compileUi(os.path.join(root, file), f)
            f.close()
            
            # cleanup import content
            f = open(outfile, 'r')
            data = f.read()
            f.close()
            
            data = re.sub('import .*_rc', '', data)
            
            # save back out the content
            f = open(outfile, 'w')
            f.write(data)
            f.close()
        
        if found and not '__init__.py' in files:
            f = open(os.path.join(root, '__init__.py'), 'w')
            f.write('# auto created for UI import')
            f.close()
260159
def create_directory(self):
        
        src = self.get_current_path()
        name, status = QtWidgets.QInputDialog.getText(
            self.tree_view, _('Create directory'), _('Name:'),
            QtWidgets.QLineEdit.Normal, '')
        if status:
            fatal_names = ['.', '..']
            for i in fatal_names:
                if i == name:
                    QtWidgets.QMessageBox.critical(
                        self.tree_view, _("Error"), _("Wrong directory name"))
                    return

            if os.path.isfile(src):
                src = os.path.dirname(src)
            dir_name = os.path.join(src, name)
            try:
                os.makedirs(dir_name, exist_ok=True)
            except OSError as e:
                QtWidgets.QMessageBox.warning(
                    self.tree_view, _('Failed to create directory'),
                    _('Failed to create directory: "%s".\n\n%s') % (dir_name, str(e)))
695168
def make_executable(path_str):
  ''' 
  '''
  try:
    mode = os.stat(path_str).st_mode
    os.chmod(path_str, mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
  except Exception as e:
    print 'Exception: %s' % e
    return None
  return path_str
1240019
def init(scope):
    
    # define wrapper compatibility symbols
    QtCore.THREADSAFE_NONE = XThreadNone()
    QtGui.QDialog = QDialog
    
    # define the importable symbols
    scope['QtCore'] = QtCore
    scope['QtGui'] = QtGui
    scope['QtWebKit'] = lazy_import('PySide.QtWebKit')
    scope['QtNetwork'] = lazy_import('PySide.QtNetwork')
    scope['QtXml'] = lazy_import('PySide.QtXml')
    
    scope['uic'] = Uic()
    scope['rcc_exe'] = 'pyside-rcc'
    
    # map overrides
    #QtCore.SIGNAL = SIGNAL
    
    # map shared core properties
    QtCore.QDate.toPyDate = lambda x: x.toPython()
    QtCore.QDateTime.toPyDateTime = lambda x: x.toPython()
    QtCore.QTime.toPyTime = lambda x: x.toPython()
    QtCore.QStringList = list
    QtCore.QString = unicode
470138
def accept(self):
        """"""
        configurations = []
        for index in range(self.stack.count()):
            filename = to_text_string(self.combo.itemText(index))
            runconfigoptions = self.stack.widget(index)
            if index == self.stack.currentIndex() and\
               not runconfigoptions.is_valid():
                return
            options = runconfigoptions.get()
            configurations.append( (filename, options) )
        _set_run_configurations(configurations)
        QDialog.accept(self)
1109854
def main():
    
    logging.basicConfig(level=logging.DEBUG)
    # create the application and the main window
    app = QtWidgets.QApplication(sys.argv)
    window = QtWidgets.QMainWindow()

    # setup ui
    ui = example_ui.Ui_MainWindow()
    ui.setupUi(window)
    ui.bt_delay_popup.addActions([
        ui.actionAction,
        ui.actionAction_C
    ])
    ui.bt_instant_popup.addActions([
        ui.actionAction,
        ui.actionAction_C
    ])
    ui.bt_menu_button_popup.addActions([
        ui.actionAction,
        ui.actionAction_C
    ])
    window.setWindowTitle('QDarkGrayStyle example')

    # tabify dock widgets to show bug #6
    window.tabifyDockWidget(ui.dockWidget1, ui.dockWidget2)

    # setup stylesheet
    app.setStyleSheet(qdarkgraystyle.load_stylesheet())

    # auto quit after 2s when testing on travis-ci
    if '--travis' in sys.argv:
        QtCore.QTimer.singleShot(2000, app.exit)

    # run
    window.show()
    app.exec_()
306389
def _detect(env):
    """"""
    QTDIR = None
    if not QTDIR:
        QTDIR = env.get('QTDIR',None)
    if not QTDIR:
        QTDIR = os.environ.get('QTDIR',None)
    if not QTDIR:
        moc = env.WhereIs('moc')
        if moc:
            QTDIR = os.path.dirname(os.path.dirname(moc))
            SCons.Warnings.warn(
                QtdirNotFound,
                "Could not detect qt, using moc executable as a hint (QTDIR=%s)" % QTDIR)
        else:
            QTDIR = None
            SCons.Warnings.warn(
                QtdirNotFound,
                "Could not detect qt, using empty QTDIR")
    return QTDIR
425396
def prompt(default=None):
    """"""
    editor = 'nano'
    with tempfile.NamedTemporaryFile(mode='r+') as tmpfile:
        if default:
            tmpfile.write(default)
            tmpfile.flush()

        child_pid = os.fork()
        is_child = child_pid == 0

        if is_child:
            os.execvp(editor, [editor, tmpfile.name])
        else:
            os.waitpid(child_pid, 0)
            tmpfile.seek(0)
            return tmpfile.read().strip()
210032
def main():
        
        app = QApplication(sys.argv)
        rlbot_icon = QtGui.QIcon(os.path.join(get_rlbot_directory(), 'img', 'rlbot_icon.png'))
        app.setWindowIcon(rlbot_icon)
        window = RLBotQTGui()
        window.show()
        app.exec_()
367805
def main():
    
    logging.basicConfig(level=logging.DEBUG)
    # create the application and the main window
    app = QtWidgets.QApplication(sys.argv)
    window = QtWidgets.QMainWindow()

    # setup ui
    ui = example_ui.Ui_MainWindow()
    ui.setupUi(window)
    ui.bt_delay_popup.addActions([
        ui.actionAction,
        ui.actionAction_C
    ])
    ui.bt_instant_popup.addActions([
        ui.actionAction,
        ui.actionAction_C
    ])
    ui.bt_menu_button_popup.addActions([
        ui.actionAction,
        ui.actionAction_C
    ])
    item = QtWidgets.QTableWidgetItem("Test")
    item.setCheckState(QtCore.Qt.Checked)
    ui.tableWidget.setItem(0, 0, item)
    window.setWindowTitle("QDarkStyle example")

    # tabify dock widgets to show bug #6
    window.tabifyDockWidget(ui.dockWidget1, ui.dockWidget2)

    # setup stylesheet
    app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())

    # auto quit after 2s when testing on travis-ci
    if "--travis" in sys.argv:
        QtCore.QTimer.singleShot(2000, app.exit)

    # run
    window.show()
    app.exec_()
567691
def create_actions(MAIN):
    """"""
    actions = MAIN.action  # actions was already taken

    """ ------ OPEN SETTINGS ------ """
    actions['open_settings'] = QAction(QIcon(ICON['settings']), 'Settings',
                                       MAIN)
    actions['open_settings'].triggered.connect(MAIN.show_settings)

    """ ------ CLOSE WINDOW ------ """
    actions['close_wndw'] = QAction(QIcon(ICON['quit']), 'Quit', MAIN)
    actions['close_wndw'].triggered.connect(MAIN.close)

    """ ------ ABOUT ------ """
    actions['about'] = QAction('About WONAMBI', MAIN)
    actions['about'].triggered.connect(MAIN.about)

    actions['aboutqt'] = QAction('About Qt', MAIN)
    actions['aboutqt'].triggered.connect(lambda: QMessageBox.aboutQt(MAIN))
908630
def start():
    """"""

    setupdir = dirname(dirname(__file__))
    curdir = os.getcwd()

    # First look on the command line for a desired config file,
    # if it's not on the command line, then look for 'setup.py'
    # in the current directory. If there, load configuration
    # from a file called 'dev.cfg'. If it's not there, the project
    # is probably installed and we'll look first for a file called
    # 'prod.cfg' in the current directory and then for a default
    # config file called 'default.cfg' packaged in the egg.
    if len(sys.argv) > 1:
        configfile = sys.argv[1]
    elif exists(join(setupdir, "setup.py")):
        configfile = join(setupdir, "dev.cfg")
    elif exists(join(curdir, "prod.cfg")):
        configfile = join(curdir, "prod.cfg")
    else:
        try:
            configfile = pkg_resources.resource_filename(
              pkg_resources.Requirement.parse("tgpisa"),
                "config/default.cfg")
        except pkg_resources.DistributionNotFound:
            raise ConfigurationError("Could not find default configuration.")

    turbogears.update_config(configfile=configfile,
        modulename="tgpisa.config")

    from tgpisa.controllers import Root

    turbogears.start_server(Root())
584396
def configure(self, ext):
        """"""
        ext.include_dirs += self.include_dirs
        ext.library_dirs += self.library_dirs
        ext.libraries += self.libraries
        ext.extra_compile_args += self.extra_compile_args
        ext.extra_link_args += self.extra_link_args
        ext.extra_objects += self.extra_objects
958753
def _write_conf(conf, path=MAIN_CF):
    '''
    
    '''
    with salt.utils.files.fopen(path, 'w') as fh_:
        for line in conf:
            line = salt.utils.stringutils.to_str(line)
            if isinstance(line, dict):
                fh_.write(' '.join(line))
            else:
                fh_.write(line)
            fh_.write('\n')
1113367
def create_mock_executable(executable_name)
      Dir.chdir(@project_path) do
        dir = mock_executable_dir(executable_name)
        FileUtils.mkdir_p(dir)
        executable_path = mock_executable_path(executable_name)
        File.open(executable_path, "w") { |io| io.puts "echo $0 $*>test_out" }
        File.chmod(0777, executable_path)
        executable_path
      end
    end