Tkinter / Tk 8.5
Today has been released a first beta of Tk 8.5, including a Ttk (tile) style engine, which makes possible the native look of widgets on MS platform, without having to install any extension. http://wiki.tcl.tk/11075 http://sourceforge.net/mailarchive/message.php?msg_name=1190813039.46fa5d6f6a06b%40webmail.nist.gov Is there a chance it will be included in 2.5.x, 2.6 or 3.0 ? -m. -- http://mail.python.org/mailman/listinfo/python-list
Re: ~ bit-wise unary operator
cau, maybe int is represented internally as a signed integer you can use numpy types: >>> import numpy >>> ~ numpy.uint16(7978) 57557 -m. On Thu, 27 Sep 2007 00:14:49 +0200, Ladislav Andel wrote: > Hello, > why ~ bit-wise unary operator returns -(x+1) and not bit inversion of > the given integer? > > example: > a = 7978 > a = ~a > python returns -7979 > > but I need to get back 57557 as in C language. > > which is also in binary > 000100101010 > and inverted > 111011010101 > > Is here any other operator or do I have to write it on my own? > > Thank you, > Lada -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter question
On Thu, 04 Oct 2007 20:16:14 -0700, goldtech wrote: > This works OK. But I notice that if I enlarge the window after the > script has run, the white listbox only gets "so" big while the grey > background enlarges. > > Is there a way to have it all white when I enlarge a window - like > what normally happens? > > > > from Tkinter import * > root = Tk() > root.title("Dirty Words") > scrollbar = Scrollbar(root) > scrollbar.pack(side=RIGHT, fill=Y) > listbox = Listbox(root, bg='white', font = "Courier 16", width=60) > listbox.pack() > i='123456789abcdefghijklmnopqrstuvwxyz' > for x in range(10): > listbox.insert(END, i) > listbox.config(yscrollcommand=scrollbar.set) > scrollbar.config(command=listbox.yview) > mainloop() try to change listbox.pack() to listbox.pack(expand=True, fill=BOTH) .. is it that you want ? -mykhal -- http://mail.python.org/mailman/listinfo/python-list
Re: Putting a line from a text file into a variable, then moving to next line
On Sun, 07 Oct 2007 12:00:44 +, Vernon Wenberg III wrote: > I'm not really sure how readline() works. Is there a way to iterate > through a file with multiple lines and then putting each line in a > variable in a loop? There are always more ways how to do it.. one of them is: f = open(filename) for line in f: # you may then strip the newline: line = line.strip('\n') # do anything you want with the line f.close() -- http://mail.python.org/mailman/listinfo/python-list
Re: Pil image module, "mode" bug..
On Sun, 07 Oct 2007 06:03:06 -0700, Abandoned wrote: > Hi.. > I find the picture color with: > im=Image.open("/%s" %name) > color=im.mode #p=black & beyaz rgb=color L=grey > > This usually work true but in these pictures: > http://malatya.meb.gov.tr/images/alt/ilsis_logo.gif > http://malatya.meb.gov.tr/images/meb.gif > > Say me P (black&white) but these pictures are color.. > > What is the reason of this ? > > I'm sorry my bad english P does mean palette, black&white is a special case of palette, with two colors. -- http://mail.python.org/mailman/listinfo/python-list
Re: Pil image module, "mode" bug..
On Sun, 07 Oct 2007 09:02:09 -0700, Abandoned wrote: > On Oct 7, 4:47 pm, Michal Bozon <[EMAIL PROTECTED]> wrote: >> On Sun, 07 Oct 2007 06:03:06 -0700, Abandoned wrote: >> > Hi.. >> > I find the picture color with: >> > im=Image.open("/%s" %name) >> > color=im.mode #p=black & beyaz rgb=color L=grey >> >> > This usually work true but in these pictures: >> >http://malatya.meb.gov.tr/images/alt/ilsis_logo.gif >> >http://malatya.meb.gov.tr/images/meb.gif >> >> > Say me P (black&white) but these pictures are color.. >> >> > What is the reason of this ? >> >> > I'm sorry my bad english >> >> P does mean palette, black&white is a special case of palette, with two >> colors. > > How can i understand the picture color ? (black &white or color or > grey) If you know how to work with RGB images, you can convert the image from the palette mode easily: img2 = img.convert(mode='RGB') Anyway, always is helpful to read the tutorial or basic documentation.. ;) MB -- http://mail.python.org/mailman/listinfo/python-list
Re: struct.unpack less than 1 byte
You are able to read single bits from file in C ? You'll have to read the bytes and than perform some bitwise operations on them to extract the bits > hello all, > > i need to read from a file a struct like this [1byte, 12bits, 12bits] > reading 1 byte or more is not a problem ... but the 12 bits values > are ... > > thanks -- http://mail.python.org/mailman/listinfo/python-list
[0..9] list (range) syntax
many Python newcomers are confused why range(10), does not include 10. If there was a proposal for the new syntax for ranges, which is known e.g. from Pascal or Ruby... >>> [0..10] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ...is there a chance to be approved ? We have had a short discussion on it at the irc, I hope that the fact that nobody agreed it is a good idea was just an accident :) -m. PS: to dream further.. >>> (0..10) or >>> (0..10) (0..10) or >>> (0..10) range(0, 11) -- http://mail.python.org/mailman/listinfo/python-list
Re: [0..9] list (range) syntax
On Thu, 25 Oct 2007 01:16:57 +0200, Wildemar Wildenburger wrote: > Michal Bozon wrote: >> many Python newcomers are confused why >> range(10), does not include 10. >> > It produces a list of ten elements. Also the documentation is quite > clear on the topic. And lastly: This will probably really bother you for > a week, then no more. > > >> If there was a proposal for the new >> syntax for ranges, which is known >> e.g. from Pascal or Ruby... >> >>>>> [0..10] >> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >> >> ...is there a chance to be approved ? >> > Quite close to none. It is too much cosmetics and too little > enhancement. What would that make possible that is impossible by now or > what would that make easier that is really hard? > > And if you really need something like that, write a function: > > def fullrange(start, end): > r = range(start, end) > r.append(end) > return r > > /W This is something completely different. The .. syntax was not meant only as something which would include the last item, but also/rather a range list syntactic shortcut: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] --> [0, 1, ... 9, 10] --> [0..10] -m. -- http://mail.python.org/mailman/listinfo/python-list
Re: Delete all not allowed characters..
On Thu, 25 Oct 2007 07:52:36 -0700, Abandoned wrote: > Hi.. > I want to delete all now allowed characters in my text. > I use this function: > > def clear(s1=""): > if s1: > allowed = > [u'+',u'0',u'1',u'2',u'3',u'4',u'5',u'6',u'7',u'8',u'9',u' ', u'Ş', > u'ş', u'Ö', u'ö', u'Ü', u'ü', u'Ç', u'ç', u'İ', u'ı', u'Ğ', u'ğ', 'A', > 'C', 'B', 'E', 'D', 'G', 'F', 'I', 'H', 'K', 'J', 'M', 'L', 'O', 'N', > 'Q', 'P', 'S', 'R', 'U', 'T', 'W', 'V', 'Y', 'X', 'Z', 'a', 'c', 'b', > 'e', 'd', 'g', 'f', 'i', 'h', 'k', 'j', 'm', 'l', 'o', 'n', 'q', 'p', > 's', 'r', 'u', 't', 'w', 'v', 'y', 'x', 'z'] > s1 = "".join(ch for ch in s1 if ch in allowed) > return s1 > > And my problem this function replace the character to "" but i > want to " " > for example: > input: Exam%^^ple > output: Exam ple > I want to this output but in my code output "Example" > How can i do quickly because the text is very long.. the list comprehension does not allow "else", but it can be used in a similar form: s2 = "" for ch in s1: s2 += ch if ch in allowed else " " (maybe this could be written more nicely) -- http://mail.python.org/mailman/listinfo/python-list
Re: Delete all not allowed characters..
> >> the list comprehension does not allow "else", but it can be used in a >> similar form: >> ( I was wrong, as Tim Chase have shown ) >> s2 = "" >> for ch in s1: >> s2 += ch if ch in allowed else " " >> >> (maybe this could be written more nicely) > > Repeatedly adding strings together in this way is about the most > inefficient, slow way of building up a long string. (Although I'm sure > somebody can come up with a worse way if they try hard enough.) > > Even though recent versions of CPython have a local optimization that > improves the performance hit of string concatenation somewhat, it is > better to use ''.join() rather than add many strings together: > String appending is not tragically slower, for strings long tens of MB, the speed makes me a difference in few tens of percents, so it is not several times slower, or so > s2 = [] > for ch in s1: > s2.append(ch if (ch in allowed) else " ") > s2 = ''.join(s2) > > Although even that doesn't come close to the efficiency and speed of > string.translate() and string.maketrans(). Try to find a way to use them. > > Here is one way, for ASCII characters. > > allowed = "abcdef" > all = string.maketrans('', '') > not_allowed = ''.join(c for c in all if c not in allowed) > table = string.maketrans(not_allowed, ' '*len(not_allowed)) > new_string = string.translate(old_string, table) Nice, I did not know that string translation exists, but Abandoned have defined allowed characters, so making a translation table for the unallowed characters, which would take nearly complete unicode character table would be inefficient. -- http://mail.python.org/mailman/listinfo/python-list