def __init__(self, amsn_conversation, parent, contacts_uid): QWidget.__init__(self, parent) self._amsn_conversation = amsn_conversation self.ui = Ui_ChatWindow() self.ui.setupUi(self) self.ui.inputWidget = InputWidget(self) self.ui.inputLayout.addWidget(self.ui.inputWidget) self._statusBar = QStatusBar(self) self.layout().addWidget(self._statusBar) self.last_sender = '' self.nickstyle = "color:#555555; margin-left:2px" self.msgstyle = "margin-left:15px" self.infostyle = "margin-left:2px; font-style:italic; color:#6d6d6d" self.loadEmoticonList() QObject.connect(self.ui.inputWidget, SIGNAL("textChanged()"), self.processInput) QObject.connect(self.ui.inputWidget, SIGNAL("enterKeyTriggered()"), self.__sendMessage) QObject.connect(self.ui.actionInsert_Emoticon, SIGNAL("triggered()"), self.showEmoticonList) self.enterShortcut = QShortcut(QKeySequence("Enter"), self.ui.inputWidget) self.nudgeShortcut = QShortcut(QKeySequence("Ctrl+G"), self) QObject.connect(self.enterShortcut, SIGNAL("activated()"), self.__sendMessage) QObject.connect(self.nudgeShortcut, SIGNAL("activated()"), self.__sendNudge) QObject.connect(self.ui.actionNudge, SIGNAL("triggered()"), self.__sendNudge) #TODO: remove this when papyon is "fixed"... sys.setappdefaultencoding("utf8")
def sys_coding(): logging.debug("In sys_coding()") locale.setlocale(locale.LC_ALL, '') try: sys.setappdefaultencoding(constant.CODING) except AttributeError: try: reload(sys) sys.setdefaultencoding(constant.CODING) except LookupError: pass
def simpleAppStartup(argv, appinfo, mwFactory, kqOptions = [], quitOnLastWindowClosed = True, raiseIt = True): """ Function to start up an application that doesn't need a specialized start up. This function is used by all of eric4's helper programs. @param argv list of commandline parameters (list of strings) @param appinfo dictionary describing the application @param mwFactory factory function generating the main widget. This function must accept the following parameter. <dl> <dt>argv</dt> <dd>list of commandline parameters (list of strings)</dd> </dl> @keyparam kqOptions list of acceptable command line options. This is only used, if the application is running under KDE and pyKDE can be loaded successfully. @keyparam quitOnLastWindowClosed flag indicating to quit the application, if the last window was closed (boolean) @keyparam raiseIt flag indicating to raise the generated application window (boolean) """ ddindex = handleArgs(argv, appinfo) app = KQApplication(argv, kqOptions) app.setQuitOnLastWindowClosed(quitOnLastWindowClosed) try: sys.setappdefaultencoding(str(Preferences.getSystem("StringEncoding"))) except AttributeError: pass setLibraryPaths() initializeResourceSearchPath() QApplication.setWindowIcon(UI.PixmapCache.getIcon("eric.png")) qt4TransDir = Preferences.getQt4TranslationsDir() if not qt4TransDir: qt4TransDir = QLibraryInfo.location(QLibraryInfo.TranslationsPath) loadTranslators(qt4TransDir, app) QTextCodec.setCodecForCStrings(\ QTextCodec.codecForName(str(Preferences.getSystem("StringEncoding"))) ) w = mwFactory(argv) if quitOnLastWindowClosed: app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()")) w.show() if raiseIt: w.raise_() return app.exec_()
if recurse: if os.path.isdir(fullname) and not os.path.islink(fullname): result = result + walk_dir(fullname, recurse, pattern, return_folders) return result if __name__ == '__main__': import time from mamewah_ini import MameWahIni #set vars cdir = sys.path[0] #_mameinfo_file = os.path.join(cdir, 'mameinfo111.xml') #_catver_ini = os.path.join(cdir, 'catver2.ini') #set to unicode encoding try: sys.setappdefaultencoding('utf-8') except AttributeError: pass #test nms feed #print read_nms_file(os.path.expanduser('~/emulators/pc/pc_games.nms')) #write filter file def wrtFilterFile(filter_filename,mwfilter): f, file_enc = open_file(filter_filename, 'w') #@UnusedVariable f.write('1\n\n') for key in _sections[1:]: l = mwfilter[key] l.sort() for item in l: if item is not None and item != '':
#!/usr/bin/env python """guitable.py -- an editable view of a database table.""" import sys sys.setappdefaultencoding("utf-8") True = 1 False = 0 from guiconfig import guiConf from guicombotableitem import GuiComboTableItem from kuralib import kuraapp from dbobj import dbtypes from qttable import QTable, QCheckTableItem, QTableItem from qt import QApplication, SIGNAL, SLOT, Qt, QFont class GuiTable(QTable): def __init__(self, parent, searchForm, editForm, *args): QTable.__init__(self, parent, *args) self.setSelectionMode(QTable.SingleRow) self.setShowGrid(True) self.app = kuraapp.app self.searchForm = searchForm self.editForm = editForm self.headers = [] self.connect(self, SIGNAL("valueChanged(int, int)"), self.commit) self.setSorting(True)
Licence: GPLv2+ """ __author__ = "Karol Będkowski" __copyright__ = "Copyright (c) Karol Będkowski, 2013" __version__ = "2013-06-01" import gettext import optparse import logging import sys reload(sys) try: sys.setappdefaultencoding("utf-8") # pylint: disable=E1101 except AttributeError: sys.setdefaultencoding("utf-8") # pylint: disable=E1101 _ = gettext.gettext _LOG = logging.getLogger(__name__) from wxgtd import version from wxgtd.model import queries def _parse_opt(): """ Parse cli options. """ optp = optparse.OptionParser(version=version.NAME + " (CLI) " + version.VERSION)
noempty = False stylesheetFile = "" colors = eric4docDefaultColors.copy() qtHelpCreation = False qtHelpOutputDir = "help" qtHelpNamespace = "" qtHelpFolder = "source" qtHelpFilterName = "unknown" qtHelpFilterAttribs = "" qtHelpTitle = "" qtHelpCreateCollection = False # Set the applications string encoding try: sys.setappdefaultencoding(str(Preferences.getSystem("StringEncoding"))) except AttributeError: pass for k, v in opts: if k in ["-o", "--outdir"]: outputDir = v elif k in ["-R", "-r", "--recursive"]: recursive = True elif k in ["-x", "--exclude"]: excludeDirs.append(v) elif k == "--exclude-file": excludePatterns.append(v) elif k in ["-i", "--noindex"]: doIndex = False elif k in ["-e", "--noempty"]:
#!/usr/bin/env python """ main.py - application starter copyright: (C) 2001, Boudewijn Rempt email: [email protected] """ import sys, locale sys.setappdefaultencoding("utf8") from qt import * from kalamapp import KalamApp from kalamdoc import KalamDoc from kalamview import KalamView import kalamconfig from resources import TRUE, FALSE def main(args): app = QApplication(args) translator = QTranslator(app) translator.load("kalam_" + locale.getlocale()[0] + ".qm", kalamconfig.get("libdir", ".")) app.installTranslator(translator) kalam = KalamApp() app.setMainWidget(kalam)
def main(): """ Main entry point into the application. """ global supportedExtensions import getopt try: opts, args = getopt.getopt(sys.argv[1:], "b:hl:o:pRrt:Vx:", ["base=", "exclude=", "exclude-file=", "extension=", "help", "language=", "oldstyle", "output=", "private", "recursive", "version", ]) except getopt.error: usage() excludeDirs = ["CVS", ".svn", "_svn", ".ropeproject", "_ropeproject", ".eric4project", "_eric4project", "dist", "build", "doc", "docs"] excludePatterns = [] outputFileName = "" recursive = False newStyle = True basePackage = "" includePrivate = False progLanguages = [] extensions = [] # Set the applications string encoding try: sys.setappdefaultencoding(str(Preferences.getSystem("StringEncoding"))) except AttributeError: pass for k, v in opts: if k in ["-o", "--output"]: outputFileName = v elif k in ["-R", "-r", "--recursive"]: recursive = True elif k in ["-x", "--exclude"]: excludeDirs.append(v) elif k == "--exclude-file": excludePatterns.append(v) elif k in ["-h", "--help"]: usage() elif k in ["-V", "--version"]: version() elif k in ["-t", "--extension"]: if not v.startswith("."): v = ".%s" % v extensions.append(v) elif k in ["--oldstyle"]: newStyle = False elif k in ["-b", "--base"]: basePackage = v elif k in ["-p", "--private"]: includePrivate = True elif k in ["-l", "--language"]: if v not in progLanguages: if v not in DocumentationTools.supportedExtensionsDictForApis.keys(): sys.stderr.write("Wrong language given: %s. Aborting\n" % v) sys.exit(1) else: progLanguages.append(v) if not args: usage() if outputFileName == "": sys.stderr.write("No output file given. Aborting\n") sys.exit(1) if len(progLanguages) == 0: progLanguages = ["Python"] for progLanguage in sorted(progLanguages): basename = "" apis = [] supportedExtensions = \ DocumentationTools.supportedExtensionsDictForApis[progLanguage] supportedExtensions.extend(extensions) if "%L" in outputFileName: outputFile = outputFileName.replace("%L", progLanguage) else: if len(progLanguages) == 1: outputFile = outputFileName else: root, ext = os.path.splitext(outputFileName) outputFile = "%s-%s%s" % (root, progLanguage.lower(), ext) for arg in args: if os.path.isdir(arg): if os.path.exists(os.path.join(arg, Utilities.joinext("__init__", ".py"))): basename = os.path.dirname(arg) if arg == '.': sys.stderr.write("The directory '.' is a package.\n") sys.stderr.write("Please repeat the call giving its real name.\n") sys.stderr.write("Ignoring the directory.\n") continue else: basename = arg if basename: basename = "%s%s" % (basename, os.sep) if recursive and not os.path.islink(arg): names = [arg] + Utilities.getDirs(arg, excludeDirs) else: names = [arg] else: basename = "" names = [arg] for filename in sorted(names): inpackage = False if os.path.isdir(filename): files = [] for ext in supportedExtensions: files.extend(glob.glob(os.path.join(filename, Utilities.joinext("*", ext)))) initFile = os.path.join(filename, Utilities.joinext("__init__", ext)) if initFile in files: inpackage = True files.remove(initFile) files.insert(0, initFile) elif progLanguage != "Python": # assume package inpackage = True else: if Utilities.isWindowsPlatform() and glob.has_magic(filename): files = glob.glob(filename) else: files = [filename] for file in files: skipIt = False for pattern in excludePatterns: if fnmatch.fnmatch(os.path.basename(file), pattern): skipIt = True break if skipIt: continue try: module = Utilities.ModuleParser.readModule(file, basename = basename, inpackage = inpackage) apiGenerator = APIGenerator(module) api = apiGenerator.genAPI(newStyle, basePackage, includePrivate) except IOError, v: sys.stderr.write("%s error: %s\n" % (file, v[1])) continue except ImportError, v: sys.stderr.write("%s error: %s\n" % (file, v)) continue for apiEntry in api: if not apiEntry in apis: apis.append(apiEntry) sys.stdout.write("-- %s -- %s ok\n" % (progLanguage, file))
def main(): """ Main entry point into the application. """ global args, mainWindow, splash, restartArgs sys.excepthook = excepthook options = [\ ("--config=configDir", "use the given directory as the one containing the config files"), ("--debug", "activate debugging output to the console"), ("--nosplash", "don't show the splash screen"), ("--noopen", "don't open anything at startup except that given in command"), ("--nokde" , "don't use KDE widgets"), ("--plugin=plugin-file", "load the given plugin file (plugin development)"), ("--start-session", "load the global session file"), ("--", "indicate that there are options for the program to be debugged"), ("", "(everything after that is considered arguments for this program)") ] kqOptions = [\ ("config \\", "use the given directory as the one containing the config files"), ("debug", "activate debugging output to the console"), ("nosplash", "don't show the splash screen"), ("noopen", "don't open anything at startup except that given in command"), ("nokde" , "don't use KDE widgets"), ("plugin \\", "load the given plugin file (plugin development)"), ("start-session", "load the global session file"), ("!+file", "") ] appinfo = Startup.makeAppInfo(sys.argv, "Eric4", "[project | files... [--] [debug-options]]", "A Python IDE", options) ddindex = Startup.handleArgs(sys.argv, appinfo) if not Utilities.checkBlacklistedVersions(): sys.exit(100) app = KQApplication(sys.argv, kqOptions) if Preferences.getUI("SingleApplicationMode"): handleSingleApplication(ddindex) # set the library paths for plugins Startup.setLibraryPaths() # set the search path for icons Startup.initializeResourceSearchPath() # generate and show a splash window, if not suppressed if "--nosplash" in sys.argv and sys.argv.index("--nosplash") < ddindex: del sys.argv[sys.argv.index("--nosplash")] splash = NoneSplashScreen() elif not Preferences.getUI("ShowSplash"): splash = NoneSplashScreen() else: splash = SplashScreen() # modify the executable search path for the PyQt4 installer if Utilities.isWindowsPlatform(): pyqtDataDir = Utilities.getPyQt4ModulesDirectory() if os.path.exists(os.path.join(pyqtDataDir, "bin")): path = os.path.join(pyqtDataDir, "bin") + os.pathsep + os.environ["PATH"] else: path = pyqtDataDir + os.pathsep + os.environ["PATH"] os.environ["PATH"] = path pluginFile = None noopen = False if "--noopen" in sys.argv and sys.argv.index("--noopen") < ddindex: del sys.argv[sys.argv.index("--noopen")] noopen = True for arg in sys.argv: if arg.startswith("--plugin=") and sys.argv.index(arg) < ddindex: # extract the plugin development option pluginFile = arg.replace("--plugin=", "").replace('"', "") sys.argv.remove(arg) pluginFile = os.path.expanduser(pluginFile) pluginFile = Utilities.normabspath(pluginFile) break # is there a set of filenames or options on the command line, # if so, pass them to the UI if len(sys.argv) > 1: args = sys.argv[1:] # Set the applications string encoding try: sys.setappdefaultencoding(str(Preferences.getSystem("StringEncoding"))) except AttributeError: pass # get the Qt4 translations directory qt4TransDir = Preferences.getQt4TranslationsDir() if not qt4TransDir: qt4TransDir = QLibraryInfo.location(QLibraryInfo.TranslationsPath) # Load translation files and install them loc = Startup.loadTranslators(qt4TransDir, app, ("qscintilla",)) QTextCodec.setCodecForCStrings(QTextCodec.codecForName(\ str(Preferences.getSystem("StringEncoding")))) splash.showMessage(QApplication.translate("eric4", "Importing packages...")) # We can only import these after creating the KQApplication because they # make Qt calls that need the KQApplication to exist. from UI.UserInterface import UserInterface splash.showMessage(QApplication.translate("eric4", "Generating Main Window...")) try: mainWindow = UserInterface(app, loc, splash, pluginFile, noopen, restartArgs) app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()")) mainWindow.show() QTimer.singleShot(0, uiStartUp) # generate a graphical error handler eMsg = QErrorMessage.qtHandler() eMsg.setMinimumSize(600, 400) # start the event loop res = app.exec_() logging.debug("Shutting down, result %d" % res) logging.shutdown() sys.exit(res) except Exception, err: raise err