Re: Nimrod programming language
Andreas Rumpf wrote: Dear Python-users, I invented a new programming language called Nimrod that combines Python's readability with C's performance. Please check it out: http://force7.de/nimrod/ Any feedback is appreciated. Regards, Andreas Rumpf __ GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT! Jetzt freischalten unter http://movieflat.web.de Looks really interesting. I think I'll give it a try later on. Thanks for your announcement. Reagrds, Listick http://www.listick.org -- http://mail.python.org/mailman/listinfo/python-list
Code - what could be done better?
Hi all, here's the main code of thc, my txt to html converter. Since I'm a beginner it is far, far, faaar away from perfect or even good :-) What could be done better? #!/usr/bin/env python # -*- coding: utf-8 -*- # thc # Copyright (C) 2007 - 2009 Listick Lorch # # i...@listick.org # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA import sys import webbrowser import texts_en as texts # you have to change only the countrycode like texts_de ... from PyQt4 import QtGui, QtCore from mainframe_ui import Ui_MainWindow as Frm import abtDialogFrame class ThcMainframe(QtGui.QMainWindow, Frm): def __init__(self): QtGui.QMainWindow.__init__(self) self.setupUi(self) # ---MEMBERS--- self.file_to_convert = '' self.file_to_write = '' self.txt_file_to_convert = '' # stores the text of the .txt file self.bgColor_R = hex(255)[2:].zfill(2) self.bgColor_G = hex(255)[2:].zfill(2) self.bgColor_B = hex(255)[2:].zfill(2) self.font_size = 0 # ---SLOTS--- # browse file to convert self.connect(self.btnBrowseFileConv, QtCore.SIGNAL(clicked()), self.onBrowseFileConv) # browse file to write self.connect(self.btnBrowseFileWrite, QtCore.SIGNAL(clicked()), self.onBrowseFileWrite) # convert self.connect(self.btnConvert, QtCore.SIGNAL(clicked()), self.onConvert) # show result self.connect(self.btnShowResult, QtCore.SIGNAL(clicked()), self.onShowResult) # select color self.connect(self.btnColorSelect, QtCore.SIGNAL(clicked()), self.SelectColor) # font size self.connect(self.horizontalSlider, QtCore.SIGNAL(changed()), self.onFontSizeChanged) # help menu self.connect(self.actionGo_to_listick_org, QtCore.SIGNAL(triggered()), self.GoToListickOrg) self.connect(self.actionAbout, QtCore.SIGNAL(triggered()), self.OpenAbout) # quit self.connect(self.btnQuit, QtCore.SIGNAL(clicked()), self.onQuit) self.connect(self.actionExit, QtCore.SIGNAL(triggered()), self.onQuit) def onBrowseFileConv(self): self.file_to_convert = QtGui.QFileDialog.getOpenFileName(self, texts.FileMenuOpen, '/home', '*.txt') self.inpFileConv.setText(self.file_to_convert) def onBrowseFileWrite(self): self.file_to_write = QtGui.QFileDialog.getSaveFileName(self, texts.FileMenuSaveAs, '/home', '*.htm*') self.inpFileWrite.setText(self.file_to_write) def onConvert(self): # read the title html_file_title = str(self.inpTitle.displayText()) # read the txt file_open = open(self.file_to_convert) print texts.FileOpened self.txtOutput.insertPlainText(texts.FileOpened) self.txt_file_to_convert = file_open.read() file_open.close() print texts.FileClosed self.txtOutput.insertPlainText(texts.FileClosed) # write html file_open = open(self.file_to_write, w) print texts.WritingFile self.txtOutput.insertPlainText(texts.WritingFile) strict_or_transitional = {True: 'Transitional', False: 'Strict'} spec = strict_or_transitional[self.rdioBtnTransitional.isChecked()] doctype = '!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 %s//EN\n' % spec file_open.write(doctype) file_open.write('HTML\n') # HTML head stuff file_open.write('HEAD\n') file_open.write('META HTTP-EQUIV=Content-Type CONTENT=text/html; charset=UTF-8\n') file_open.write('TITLE%s/TITLE\n' % html_file_title) file_open.write('META NAME=Generator CONTENT=thc - Txt-to-Html-Converter %s\n' % texts.versionInfo) file_open.write('/HEAD\n') #head end #HTML body file_open.write('BODY BGCOLOR=#%s%s%s\n' % (self.bgColor_R, self.bgColor_G, self.bgColor_B)) file_open.write(self.txt_file_to_convert) file_open.write('BR') # Created-with-thc notice file_open.write(texts.createdWithNote)
What would YOU like to see in a txt to html converter?
As you might have mentioned I'm just working on a txt to html converter called thc. This project is intended for me to learn Python and now pyQT4 to which I changed a few days ago (started with Tkinter). I have implemented the following features so far: - Giving a title for the html - Choose whether it's Transitional or Strict Doctype - Select a background color - Show the converted file with the standard browser - Working on a font size slider I don't really know if this is of any use for anybody but it's just a fun project by a beginner :-) Now I'd like to know what kind of features you'd like to see in version 0.3 of thc!? Please post them... Have fun! Listick http://www.lictick.org -- http://mail.python.org/mailman/listinfo/python-list
Re: What would YOU like to see in a txt to html converter?
Will Wang wrote: Florian == Florian Wollenschein florian.wollensch...@fernuni-hagen.de writes: Florian As you might have mentioned I'm just working on a txt to html converter called Florian thc. This project is intended for me to learn Python and now pyQT4 to which I Florian changed a few days ago (started with Tkinter). Florian I have implemented the following features so far: Florian - Giving a title for the html Florian - Choose whether it's Transitional or Strict Doctype Florian - Select a background color Florian - Show the converted file with the standard browser Florian - Working on a font size slider Florian I don't really know if this is of any use for anybody but it's just a fun Florian project by a beginner :-) Florian Now I'd like to know what kind of features you'd like to see in version 0.3 of Florian thc!? Florian Please post them... Florian Have fun! Florian Listick Florian http://www.lictick.org You could learn something from emacs-muse. That plugin can help emacs to convert txt to html, tex, pdf, docbook and some other document format. In emacs-muse, the title and subtitle is defined like this: *emphasis* **strong emphasis** ***very strong emphasis*** _underlined_ =verbatim and monospace= emacs-muse : http://mwolson.org/projects/EmacsMuse.html Thank you for this information. I already thought of using dots or asterisks or whatever to let the user format the text instead of using html tags (this would be quite paradox ;-) Please keep on posting ideas... Thanks again, Listick http://www.listick.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Newcomer to Python tutorial question
Alan Cameron wrote: I am not sure of this is the right place to ask a question about the tutorial http://docs.python.org/3.0/tutorial/datastructures.html#sets why is the printed result of basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'} print(basket) {'orange', 'banana', 'pear', 'apple'} in the sequence given? A set is not ordered and eliminates duplicate elements. So the output is random in terms of the order and only shows each single item once... Correct me if I'm wrong :-) Listick http://www.listick.org -- http://mail.python.org/mailman/listinfo/python-list
Re: hex(dummy)[2:] - issue...
Tim Chase wrote: I need some advice :-) I'm using hex(dummy)[2:] to represent a color in hexadecimal format for the bgcolor in an html file. dummy is the color value in RGB of course... Now, if there's an R, G or B value of zero, this command only prints one single 0 instead of two. What's wrong with the code? You can try PLACES = 2 # 6? hex(dummy)[2:].zfill(PLACES) Alternatively, you can output decimal numbers in HTML/CSS with rgb(r, g, b) such as style=rgb(255,0,0) However, I recommend doing this via CSS unless you have a strong reason to sully your HTML with style information. -tkc hey tkc, I used your first alternative. This did it! Thanks a lot. I think I will write the style stuff into a .css file in the next few days but until then I'm just working on get my program to work... Listick http://www.listick.org -- http://mail.python.org/mailman/listinfo/python-list
Re: thc v0.3 - txt to html converter - better code?
Richard Brodie wrote: Stefan Behnel stefan...@behnel.de wrote in message news:4a008996$0$31862$9b4e6...@newsspool3.arcor-online.net... language_map = {'English': 'EN', 'Deutsch': 'DE'} strict_or_transitional = {True: 'Transitional', False: 'Strict'} # this will raise a KeyError for unknown languages language = language_map[ self.cmboBoxLang.currentText() ] # this assumes that isChecked() returns True or False spec = strict_or_transitional[self.rdioBtnTransitional.isChecked()] doctype = '!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 %s/%s\n' % ( spec, language) Incidentally, the language in an HTML DOCTYPE refers to the language of the DTD, not the document. It's never correct to use //DE in an HTML page, unless you have a custom (German) DTD. So the code can be improved further by cutting that part out. strict_or_transitional = {True: 'Transitional', False: 'Strict'} # this assumes that isChecked() returns True or False spec = strict_or_transitional[self.rdioBtnTransitional.isChecked()] doctype = '!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 %s//EN\n' % spec Yes, that's true. I missed that. Thanks for the information. And many thanks to Stefan. -- http://mail.python.org/mailman/listinfo/python-list
hex(dummy)[2:] - issue...
Hi there, I need some advice :-) I'm using hex(dummy)[2:] to represent a color in hexadecimal format for the bgcolor in an html file. dummy is the color value in RGB of course... Now, if there's an R, G or B value of zero, this command only prints one single 0 instead of two. What's wrong with the code? Thanks, Listick http://www.listick.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Open a dialog from MainWindow - pyQT4 - Beginner :-)
nickga...@gmail.com wrote: On May 4, 7:31 pm, Florian Wollenschein florian.wollensch...@fernuni- Hagen.de wrote: Dear folks, I'm just working on a pyQT4 version of my txt to html converter thc (see listick.org for details). I created the MainWindow with QT Designer and then converted it to .py with pyuic4. It works well so far. Then I created a new UI for my abtDialog (about dialog for my application). I did the same as with the MainWindow, so I have two UIs and two *_ui.py files now. How can I open the dialog from my main application class? Here's part of the code I'm using: ... self.connect(self.actionAbout, QtCore.SIGNAL(triggered()), self.OpenAbout) ... def OpenAbout(self): pass ... The OpenAbout function should open the dialog. I've already tried a abtDialog.show() after creating it via abtDialog = ThcAboutDialog() (ThcAboutDialog is the class for this dlg). Any ideas? Thanks, Listick Lorchhttp://www.listick.org PS: Keep in mind that I'm quite a beginner in the field of python and qt... def OpenAbout(self): # don't forget to connect the Ok-button of this about-dialog to QDialog::accept() ;-) abtDialog.setAttribute(QtCore.Qt.WA_DeleteOnClose) abtDialog.exec_() R3 ps: you could take a look at a QMessageBox::information or so to make this more simple Wow, thanks for your help. Now it's working :-) Great. Regards, Listick -- http://mail.python.org/mailman/listinfo/python-list
thc v0.3 - txt to html converter - better code?
Hi all, here's some code of thc, my txt to html converter programmed with Python and pyQT4: --- if self.rdioBtnTransitional.isChecked(): if self.cmboBoxLang.currentText() == English: file_open.write('!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN' + '\n') elif self.cmboBoxLang.currentText() == German: file_open.write('!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//DE' + '\n') else: file_open.write('!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Strict//EN' + '\n') if self.cmboBoxLang.currentText() == English: file_open.write('!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Strict//EN' + '\n') elif self.cmboBoxLang.currentText() == German: file_open.write('!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Strict/DE' + '\n') Do you have any ideas for a better code than that? Could this be done smarter, shorter, whatever!? Thanks in advance, Listick http://www.listick.org -- http://mail.python.org/mailman/listinfo/python-list
Open a dialog from MainWindow - pyQT4 - Beginner :-)
Dear folks, I'm just working on a pyQT4 version of my txt to html converter thc (see listick.org for details). I created the MainWindow with QT Designer and then converted it to .py with pyuic4. It works well so far. Then I created a new UI for my abtDialog (about dialog for my application). I did the same as with the MainWindow, so I have two UIs and two *_ui.py files now. How can I open the dialog from my main application class? Here's part of the code I'm using: ... self.connect(self.actionAbout, QtCore.SIGNAL(triggered()), self.OpenAbout) ... def OpenAbout(self): pass ... The OpenAbout function should open the dialog. I've already tried a abtDialog.show() after creating it via abtDialog = ThcAboutDialog() (ThcAboutDialog is the class for this dlg). Any ideas? Thanks, Listick Lorch http://www.listick.org PS: Keep in mind that I'm quite a beginner in the field of python and qt... -- http://mail.python.org/mailman/listinfo/python-list