[Tutor] open email client from Help menu
Hi every one, In my program, I want to have "Report Bug..." under Help menu. So, whenever user clicks on it, it will open an email client for reporting bugs with the given address. How can I do this? I set text to actionReportBug like this: Report Bug... but it doesn't support html tag. Any method? dada ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] get_python_lib()
Hi list, I was just wondering why the below function return different location on different machine? import distutils.sysconfig distutils.sysconfig.get_python_lib() On my computer: '/usr/lib/python2.5/site-packages' On my friend's computer: '/usr/local/lib/python2.5/site-packages' What is the difference between these two? Note: I have both location on my filestem. Thanks for your input. dada ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] number of nodes
Hello everyone, textp = xmldoc.getElementsByTagName('text:p') from the example above, How can I know how many node are there? Thanks, da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] remove not-empty directory
Hi all, Just a quick question again, how can I remove not-empty directory in python? assumed I have the following directory: ( temp/a/b/ temp/a/c/d.odt temp/e.xml) I want to remove the whole temp/ directory. Thanks :) da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] getAttribute
Hello all, Could anyone help me by giving example of getAttribute xmldata = ziparchive.read("content.xml") xmldoc = minidom.parseString(xmldata) officeNode = xmldoc.getElementsByTagName('office:text') I have another function: def go_thru (nodelist): for x in range(nodelist.length): node = nodelist[x] i = 0 print node.getAttribute('text:style-name') go_thru(officeNode) #Calling function I always get error message: AttributeError: Text instance has no attribute 'getAttribute' Could anyone give an explanation? Thanks a lot, da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] file?
Hi all, How can we know that one specific file is already exist in filesystem? for instance, I want to read zipfile by issuing code: import zipfile ziparchive = zipfile.ZipFile(inputfilename, "r") if the inputfilename doesn't exist then an error would be occurred. I want to catch up this special case first. Thanks, da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] encoding
Hi all, Does anybody know how to decode to Windows Latin ("ANSI") I know how to decode to utf-8: stringinput = stringinput.decode('utf-8') but while I use stringinput = stringinput.decode('ANSI') LookupError: unknown encoding: ANSI so what is the correct way to do it? Thanks and !Happy Khmer New Year! kakada ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] dictionary datatype
Hello all, For example, I have a dictionary: dict1 = { 0x2018:u'k', 0x2019:u'd'} I assign: n = 0x2018 print dict1[n] Then: KeyError: '0x2018' But I can call directly: print dict1[0x2018] So, what is wrong with this? How can I solve it? Thx kakada ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] dictionary datatype
It also works for me now:) First i tried it with Konsole in Kate and it's not working. It sometimes happen with assignment statement: i += 1 (not working) i+= 1(working) but later on I tested it again and both are working. Thanks for your help, though. da Jason Massey wrote: > Works for me: > > >>> dict1 = { 0x2018:u'k', 0x2019:u'd'} > >>> n = 0x2018 > >>> print dict1[n] > k > >>> > > On 4/11/06, * kakada* <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > Hello all, > > For example, I have a dictionary: > dict1 = { 0x2018:u'k', 0x2019:u'd'} > > I assign: > n = 0x2018 > print dict1[n] > > Then: > KeyError: '0x2018' > > But I can call directly: > print dict1[0x2018] > > So, what is wrong with this? How can I solve it? > > Thx > > kakada > ___ > Tutor maillist - Tutor@python.org <mailto:Tutor@python.org> > http://mail.python.org/mailman/listinfo/tutor > > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] encode
Hi again folks, I wonder if we can check the encoding of text in one text file. user is free to encode the file whether Latin1, utf-8, ANSI... Any ideas? Thx da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [Linux] open a file in any home "~" ?
learner404 wrote: > It works great, thanks very much to the three of you for these > light-speed answers ... I love this list ! > > Wesley, I've just pre-order your new edition "Core Python programming" > on amazon France, it looks great. :) > > Thanks I love this list too. Da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] StringIO
Hello list, I want to use the module StringIO as read and write strings as files, I looked into document but cannot understand. Could anyone give me a simple example? something like: from StringIO import * fin = StringIO("abc") . How can I used fin? Thanks, da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] StringIO
Danny Yoo wrote: >> I want to use the module StringIO as read and write strings as files, >> I looked into document but cannot understand. Could anyone give me a >> simple example? >> >> something like: >> from StringIO import * >> fin = StringIO("abc") >> . >> How can I used fin? > > 'fin' is a file-like object at this point, so you can do things like: > > fin.read(1) > > to get a single byte. The list of things we can do with file-like > objects is here: > > http://www.python.org/doc/lib/bltin-file-objects.html > > > Does this help? Good luck! Actually, what I want is creating a kind of file that is just located in memory not file system. I want to have a filename for my convert(inputFileName, outputFileName) How can I get filename? doing: fin.name() is impossible! All above, I want to test it in unittest. > > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to import a module which was not in the current working directory?
Hi Linda, Let say you have a tool named convert.py and other module (processing.py) in modules folder. In modules folder create an empty file named __init__.py In convert.py do: from modules import processing.py It would work. da linda.s wrote: > Hi, > How to import a module which was not in the current working directory? > Thanks, > Linda > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] combo box
Dear Friends, I am now working on GUI python (Tkinter). I want to use combobox as my widget, but I cannot find it in any document. Does anybody have experience with that? Thanks, da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] combo box
Michael Lange wrote: > On Tue, 06 Jun 2006 13:39:21 +0700 > kakada <[EMAIL PROTECTED]> wrote: > > >> Dear Friends, >> >> I am now working on GUI python (Tkinter). >> I want to use combobox as my widget, but I cannot find it in any document. >> >> Does anybody have experience with that? >> >> > > There is no ComboBox widget in plain Tkinter. > Probably the easiest way to get one is to use Tix which is included in the > windows python > distribution and should be available in any recent linux distro. > > If you want to use Tix simply replace the import line > > from Tkinter import * > > with > > from Tix import * > > You then can use your Tknter widgets as usual, plus a nice set of extra > widgets (ComboBox, NoteBook, DirTree etc.) . > > I hope this helps > > Michael > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > > Thank Michael, How about putting an icon on an Windows Manager, do you know? da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] icon on windows manager
Hi everyone! Does any body know how to put icon on windows manager using Tix module? Thanks, da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] error when installing sip-4.4.5
Hello list, I am on the way of learning QT design. I need to have pyQT installed. In the meanwhile, It needs sip-4.4.5 before proceed. I went across with the steps: python configure.py ...ok make In this step, I got alot of errors as follow and some more: siplib.c: In function ‘sipGetAddress’: siplib.c:4473: error: ‘sipWrapper’ has no member named ‘flags’ siplib.c:4474: error: ‘sipWrapper’ has no member named ‘u’ siplib.c:4476: error: ‘sipWrapper’ has no member named ‘flags’ siplib.c:4477: error: ‘sipWrapper’ has no member named ‘u’ siplib.c:4479: error: ‘sipWrapper’ has no member named ‘u’ I try to search for sip in yast, and try to install all relevant package, still I got the same error. Could any body can help me, please? Thanks, da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] treeWidget in QT Designer
Hi there, I am trying to build GUI python using Qt4. I am working with treeWidget to view my data. With the first load, I want the selected item go to the first row by doing: curItem = self.ui.treeWidget.itemAt(1,1) self.ui.treeWidget.setCurrentItem(curItem) It's ok. Then I want it jump to 4th row by doing curItem = self.ui.treeWidget.itemAt(4,1) self.ui.treeWidget.setCurrentItem(curItem) This time is not ok for me, It goes somewhere else. I have read the document about Qtreewidget, but I found it is difficult to understand. Could you please help to explain in an easy way? Thanks a lot, da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] playing around with function
Hello, I have problem with function jumping: in my class, I have three function here: def gotoNextFuzzy(self): state = "isfuzzy" self.navigationNext(state) def gotoNextFuzzy(self): state = "isapproved" self.navigationNext(state) def navigationNext(self,state): if (self.getCurrentItem() == 0): return 0 id = int(self.item.text(0)) for i in range(id,775): i += 1 state = if (i == 775): self.warningMessage() else: if self.store.units[i].state(): curItem = self.ui.treeWidget.topLevelItem(i) self.ui.treeWidget.setCurrentItem(curItem) self.ui.txtSource.setHtml(self.store.units[i].source) self.ui.txtTarget.setHtml(self.store.units[i].target) break and one calling built-in function: QtCore.QObject.connect(self.ui.btnNF,QtCore.SIGNAL("pressed()"),self.gotoNextFuzzy) and error said: Attribute Error: no attribute state Please understand my idea that I just want to replace the state in line if self.store.units[i].state(): with isfuzzy or isapproved or istranslated... and if I do as follow: if self.store.units[i].isfuzzy(): then it works. please also note that: isfuzzy() isapproved() istranslated() are the boolean function in other class. Does anybody have any solution on this coding style? Thanks, da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] playing around with function
Thank Alan and Luke, My coding is divided up into many modules and import from one to another. Here is my editor.py interface. #!/usr/bin/python # -*- coding: utf8 -*- import sys import application_rc from PyQt4 import QtCore, QtGui from ui_editor import Ui_MainWindow from translate.storage import factory import Display class MainWindow(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.numApproved = 0 self.numFuzzy = 0 self.numTranslated = 0 #events go here QtCore.QObject.connect(self.ui.treeWidget, QtCore.SIGNAL("itemSelectionChanged()"), self.updateField) QtCore.QObject.connect(self.ui.cmbMsgFilter, QtCore.SIGNAL("activated(int)"), self.setFilter) QtCore.QObject.connect(self.ui.chkfuzzy,QtCore.SIGNAL("stateChanged(int)"),self.toggleFuzzy) QtCore.QObject.connect(self.ui.chkapproved,QtCore.SIGNAL("toggled(bool)"),self.toggleApproved) QtCore.QObject.connect(self.ui.btnsource2target,QtCore.SIGNAL("pressed()"),self.source2target) QtCore.QObject.connect(self.ui.btnRemoveAllTU,QtCore.SIGNAL("pressed()"),self.removeAllTrans) QtCore.QObject.connect(self.ui.btnNA,QtCore.SIGNAL("pressed()"),self.gotoNA) QtCore.QObject.connect(self.ui.btnPA,QtCore.SIGNAL("pressed()"),self.gotoPA) QtCore.QObject.connect(self.ui.btnNF,QtCore.SIGNAL("pressed()"),self.gotoNF) QtCore.QObject.connect(self.ui.btnNT,QtCore.SIGNAL("pressed()"),self.gotoNT) QtCore.QObject.connect(self.ui.btnNU,QtCore.SIGNAL("pressed()"),self.gotoNU) QtCore.QObject.connect(self.ui.btnPF,QtCore.SIGNAL("pressed()"),self.gotoPF) QtCore.QObject.connect(self.ui.btnPU,QtCore.SIGNAL("pressed()"),self.gotoPU) QtCore.QObject.connect(self.ui.btnPT,QtCore.SIGNAL("pressed()"),self.gotoPT) QtCore.QMetaObject.connectSlotsByName(self) def newWindows(self): print "new windows" self.other = Ui_MainWindow() self.other.windowList.append(other) self.other.show() def openFile(self): fileName = QtGui.QFileDialog.getOpenFileName(self, self.tr("Open Xliff File"), QtCore.QDir.currentPath(), self.tr("XLIFF Files (*.xliff *.xml *.xlf);;All File(*.*)")) if fileName.isEmpty(): self.setWindowTitle( self.tr("WordForge Translation Editor v.05 - ") + "untitle") else: self.setWindowTitle( self.tr("WordForge Translation Editor v.05 - ") + str(fileName)) self.title = fileName self.store = factory.getobject(str(fileName)) self.uf = Display.Display(self.ui, self.store) import FirstShow fs = FirstShow.FirstShow(self.ui, self.store) fs.firstShow() def save(self): if self.title.isEmpty(): return self.saveAs() else: return self.store.savefile(str(self.title)) def saveAs(self): fileName = QtGui.QFileDialog.getSaveFileName(self, self.tr("Save Xliff File"), QtCore.QDir.currentPath(), self.tr("XLIFF Files (*.xliff *.xml *.xlf)")) if fileName.isEmpty(): return self.store.savefile(str(fileName)) self.ui.cmbMsgFilter.addItem ('Not filtered') self.ui.cmbMsgFilter.addItem ('fuzzy') self.ui.cmbMsgFilter.addItem ('translated') self.ui.cmbMsgFilter.addItem ('untranslated') def getCurrentItem(self): try: self.item = self.ui.treeWidget.selectedItems()[0] except IndexError: return False # I have change my code style like this: def gotoNF(self): self.state = "NF" self.navigationNext(self.state) def gotoNT(self): self.state = "NT" self.navigationNext(self.state) def gotoNU(self): self.state = "NU" self.navigationNext(self.state) def gotoNA(self): self.state = "NA" self.navigationNext(self.state) def gotoPA(self): self.state = "PA" self.navigationPrevious(self.state) def gotoPT(self): self.state = "PT" self.navigationPrevious(self.state) def gotoPU(self): self.state = "PU" self.navigationPrevious(self.state) def gotoPF(self): self.state = "PF" self.navigationPrevious(self.state) def navigated(self): if (self.state == 'NF') and (self.store.units[int(self.id)].isfuzzy()): return True if (self.state == 'PF') and (self.store.units[int(self.id)].isfuzzy()): return True if (self.state == 'NT') and (self.store.units[int(self.id)].istranslated()): return True
Re: [Tutor] playing around with function
បានសរសេរ kakada: > Thank Alan and Luke, > > My coding is divided up into many modules and import from one to another. > Here is my editor.py interface. > > > #!/usr/bin/python > # -*- coding: utf8 -*- > > import sys > import application_rc > from PyQt4 import QtCore, QtGui > from ui_editor import Ui_MainWindow > from translate.storage import factory > import Display > > > class MainWindow(QtGui.QMainWindow): > def __init__(self): > QtGui.QMainWindow.__init__(self) > > self.ui = Ui_MainWindow() > self.ui.setupUi(self) > > self.numApproved = 0 > self.numFuzzy = 0 > self.numTranslated = 0 > > #events go here > QtCore.QObject.connect(self.ui.treeWidget, > QtCore.SIGNAL("itemSelectionChanged()"), self.updateField) > QtCore.QObject.connect(self.ui.cmbMsgFilter, > QtCore.SIGNAL("activated(int)"), self.setFilter) > > QtCore.QObject.connect(self.ui.chkfuzzy,QtCore.SIGNAL("stateChanged(int)"),self.toggleFuzzy) > > QtCore.QObject.connect(self.ui.chkapproved,QtCore.SIGNAL("toggled(bool)"),self.toggleApproved) > > QtCore.QObject.connect(self.ui.btnsource2target,QtCore.SIGNAL("pressed()"),self.source2target) > > QtCore.QObject.connect(self.ui.btnRemoveAllTU,QtCore.SIGNAL("pressed()"),self.removeAllTrans) > > QtCore.QObject.connect(self.ui.btnNA,QtCore.SIGNAL("pressed()"),self.gotoNA) > > QtCore.QObject.connect(self.ui.btnPA,QtCore.SIGNAL("pressed()"),self.gotoPA) > > QtCore.QObject.connect(self.ui.btnNF,QtCore.SIGNAL("pressed()"),self.gotoNF) > > QtCore.QObject.connect(self.ui.btnNT,QtCore.SIGNAL("pressed()"),self.gotoNT) > > QtCore.QObject.connect(self.ui.btnNU,QtCore.SIGNAL("pressed()"),self.gotoNU) > > QtCore.QObject.connect(self.ui.btnPF,QtCore.SIGNAL("pressed()"),self.gotoPF) > > QtCore.QObject.connect(self.ui.btnPU,QtCore.SIGNAL("pressed()"),self.gotoPU) > > QtCore.QObject.connect(self.ui.btnPT,QtCore.SIGNAL("pressed()"),self.gotoPT) > QtCore.QMetaObject.connectSlotsByName(self) > > > > > def newWindows(self): > print "new windows" > self.other = Ui_MainWindow() > self.other.windowList.append(other) > self.other.show() > > def openFile(self): > fileName = QtGui.QFileDialog.getOpenFileName(self, self.tr("Open > Xliff File"), > > QtCore.QDir.currentPath(), > self.tr("XLIFF > Files (*.xliff *.xml *.xlf);;All File(*.*)")) > > if fileName.isEmpty(): > self.setWindowTitle( self.tr("WordForge Translation Editor > v.05 - ") + "untitle") > else: > self.setWindowTitle( self.tr("WordForge Translation Editor > v.05 - ") + str(fileName)) > self.title = fileName > self.store = factory.getobject(str(fileName)) > self.uf = Display.Display(self.ui, self.store) > > import FirstShow > fs = FirstShow.FirstShow(self.ui, self.store) > fs.firstShow() > > def save(self): > if self.title.isEmpty(): > return self.saveAs() > else: > return self.store.savefile(str(self.title)) > > def saveAs(self): > fileName = QtGui.QFileDialog.getSaveFileName(self, self.tr("Save > Xliff File"), > > QtCore.QDir.currentPath(), > self.tr("XLIFF > Files (*.xliff *.xml *.xlf)")) > if fileName.isEmpty(): > return > > self.store.savefile(str(fileName)) > > self.ui.cmbMsgFilter.addItem ('Not filtered') > self.ui.cmbMsgFilter.addItem ('fuzzy') > self.ui.cmbMsgFilter.addItem ('translated') > self.ui.cmbMsgFilter.addItem ('untranslated') > > > def getCurrentItem(self): > try: > self.item = self.ui.treeWidget.selectedItems()[0] > except IndexError: > return False > > # I have change my code style like this: > > def gotoNF(self): > self.state = "NF" > self.navigationNext(self.state) > def gotoNT(self): > self.state = "NT" > self.navigationNext(self.state) >
[Tutor] python import problem
Hi all, I have problem with import statement. supposed that I have two files in different folders : modules/myfile.py and translate/factory.py. the folders modules and translate are in the same level, so if I want to import factory.py into myfile.py, how can I do? I have already done in myfile.py: from translate import factory but it is still not work. Any solution? Thanks and regards, da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] python import problem
បានសរសេរ Alan Gauld: Hi Alan, >> the folders modules and translate are in the same level, so if I want to >> import factory.py into myfile.py, how can I do? > > You need to make your folders into packages. > Its fairly simple, you basically create an init.py file > But its worth reading about packages in the docs > Come back here ifv you have any questions after that. Sure, I can do it if I move translate folder into modules folder then create an empty init.py file. But I want another way, and PYTHONPATH is your right suggestion > > The other way would be to add each folder to > your PYTHONPATH It works for me now: mport sys import os.path sys.path.append(os.path.join(sys.path[0] ,"translate")) Cheers, da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] cannot pickle instancemethod objects
Dear everyone, I got a problem while pickling a class object. I have done something as below: pickleFile = open(filename, 'wb') pickle.dump(matcher, pickleFile) pickleFile.close() where matcher is class object and I got the follow errors: Traceback (most recent call last): File "/usr/lib/python2.5/pickle.py", line 1362, in dump Pickler(file, protocol).dump(obj) File "/usr/lib/python2.5/pickle.py", line 224, in dump self.save(obj) File "/usr/lib/python2.5/pickle.py", line 286, in save f(self, obj) # Call unbound method with explicit self File "/usr/lib/python2.5/pickle.py", line 725, in save_inst save(stuff) File "/usr/lib/python2.5/pickle.py", line 286, in save f(self, obj) # Call unbound method with explicit self File "/usr/lib/python2.5/pickle.py", line 649, in save_dict self._batch_setitems(obj.iteritems()) File "/usr/lib/python2.5/pickle.py", line 663, in _batch_setitems save(v) File "/usr/lib/python2.5/pickle.py", line 286, in save f(self, obj) # Call unbound method with explicit self File "/usr/lib/python2.5/pickle.py", line 725, in save_inst save(stuff) File "/usr/lib/python2.5/pickle.py", line 286, in save f(self, obj) # Call unbound method with explicit self File "/usr/lib/python2.5/pickle.py", line 649, in save_dict self._batch_setitems(obj.iteritems()) File "/usr/lib/python2.5/pickle.py", line 663, in _batch_setitems save(v) File "/usr/lib/python2.5/pickle.py", line 306, in save rv = reduce(self.proto) File "/usr/lib/python2.5/copy_reg.py", line 69, in _reduce_ex raise TypeError, "can't pickle %s objects" % base.__name__ TypeError: can't pickle instancemethod objects Does anybody please point me what could be a problem here? Thanks very much for your help! da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] cannot pickle instancemethod objects
នៅថ្ងៃ ពុធ 13 មិថុនា 2007 19:09, Kent Johnson បានសរសេរថា ៖ > hok kakada wrote: > >> What kind of object is matcher? Does it have any attributes that are > >> functions? (Not methods you defined for the class, but functions or > >> methods that you assign to attributes of self.) > > > > Actually, I use the translate-toolkit from > > http://translate.sourceforge.net/snapshots/translate-toolkit-1.0.1rc1/ > > in translate/search/match.py: > > if comparer is None: > > comparer = lshtein.LevenshteinComparer(max_length) > > > > self.comparer = comparer > > > > I just found the problem that it is because of the LevenshteinComparer. > > Once I assign self.comparer = None, the I can dump the matcher > > successfully. However, I still don't understand what could be wrong with > > LevenshteinComparer. > > I think the problem is this code in LevenshteinComparer.__init__(): > > if Levenshtein: > self.distance = self.native_distance > else: > self.distance = self.python_distance > > which assigns an instance method to an instance attribute; this is the > instancemethod that can't be pickled. Ok...but how can we deal with it? Kind Regards, da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] save configuration of one application.
Hi, Can anybody guide me how to write the code for configure one application? For example, I want to set Font and Color for a textbox; later when the application is opened again. the previous font is set. So, which related function are used to form this feature? Thanks, da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] save configuration of one application.
On Wednesday 04 October 2006 11:54, John Fouhy wrote: > On 04/10/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > > you can make a config.ini file and use that one module that parses ini > > files. > > I can't remember what it's called. > > configparser I think, but I wouldn't bet my life on it :) > > Yes, ConfigParser. > > The docs for ConfigParser are a bit confusing in places (IMO), but > there are people here who can help if you get stuck. > > > Or you could just write the settings out to a file. > > Using ConfigParser means your configuratino files will be > human-readable and human-editable. If you don't care about that, you > could stick them in a dictionary and use pickle to write it to a file. > Or use the shelve module. > > > If you choose to go the latter route, keep in mind that modules are > > compiled to .pyc files upon importation, > > so you'll have to remove those anytime you modify config.py or the old > > code will be used instead. > > The python interpreter should check the timestamps on foo.py vs > foo.pyc, and recompile if it thinks things have changed. Thank both of you. I'd have added some points about it. I used PyQt for designing GUI. Hence, in this case, I want to open a Font Dialog box in order to choose fontname, size and so on. Then set all these values to the textEdit. For the secode time we open the font dialog, the previous selected font will be set to the font family and font size of the font dialog. Is there any way to do it? Thanks again, da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] python2vb.net
Dear All, A friend of mine is well programming in vb.net and C#. He got a python sourcecode of KhmerConverter tool. He would like to port to either vn.net or C#. Are there any tools to do this? Thanks, da ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] How to set value back to .conf file
Hi all, I just start to use ConfigParser to store the configuration for my application. I surfed the mails related to ConfigParser, however I couldn't found the way of how to set value back to the .conf file. Let say, I have a test.conf file with: [General] userName="da" later on, I wanna add another option: email="[EMAIL PROTECTED]" I did the following: import ConfigParser conf = ConfigParser.ConfigParser() conf.read('test.conf') conf.set('General', 'email', '[EMAIL PROTECTED]' print conf.items('General') [('username','da'),('email','[EMAIL PROTECTED]')] But when I look into the file test.conf directly, I didn't see the option 'email' . I don't know what I am missing here? Or i need to write it to the file using conf.write(fp)? If so, how can I get this file pointer? Thanks very much for your input. da -- Ms.Kakada Hok Open Source Engineer KhmerOS project Open Institute Organization H/P:(+855-12) 653 155 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor