Weird list conversion

2015-12-13 Thread high5storage
Hi all,

  f = open("stairs.bin", "rb") 
  data = list(f.read(16))
  print data

returns

['=', '\x04', '\x00', '\x05', '\x00', '\x01', '\x00', '\x00', '\x00', '\x00', 
'\x00', '\x00', '\x00', '\x00', '\x00', '\x00']

The first byte of the file is 0x3D according to my hex editor, so why does 
Python return '=' and not '\x3D'?

As always, thanks for any help!
-- 
https://mail.python.org/mailman/listinfo/python-list


Fast pythonic way to process a huge integer list

2016-01-06 Thread high5storage

I have a list of 163.840 integers. What is a fast & pythonic way to process 
this list in 1,280 chunks of 128 integers?

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter spacing

2016-01-26 Thread high5storage
On Monday, January 25, 2016 at 7:41:57 PM UTC-8, KP wrote:
> If I want to have some space between, say, btn_last & btn_new, will I have to 
> use a dummy label in between these two or is there a better way?
> 
> Thanks for any help, as always!
> 
> 
> 
> 
> from tkinter import *
> from tkinter import ttk
> 
> root = Tk()
> root.geometry("822x600+100+100")
> nav_bar = ttk.Frame(root, borderwidth=2, relief='ridge', padding=(10, 3, 10, 
> 3))
> 
> btn_first  = ttk.Button(nav_bar, text='|<', width=4)  # for buttons showing 
> text only, this will be text units (= average characters?)
> btn_prev   = ttk.Button(nav_bar, text='<',  width=4)  # for image buttons, it 
> will be in pixels 
> btn_next   = ttk.Button(nav_bar, text='>',  width=4)
> btn_last   = ttk.Button(nav_bar, text='>|', width=4)
> btn_new= ttk.Button(nav_bar, text='New')
> btn_edit   = ttk.Button(nav_bar, text='Edit')
> btn_delete = ttk.Button(nav_bar, text='Delete')
> btn_cancel = ttk.Button(nav_bar, text='Cancel')
> btn_print  = ttk.Button(nav_bar, text='Print')
> btn_help   = ttk.Button(nav_bar, text='Help')
> btn_save   = ttk.Button(nav_bar, text='Save')
> lbl_Recs   = ttk.Label(nav_bar,  text='Records')
> lbl_RCount = ttk.Label(nav_bar,  text='0 ', width=10, borderwidth=2, 
> relief='sunken', anchor='e')  # fake entry look
> 
> nav_bar.grid(column=0, row=0, columnspan=13)
> 
> btn_first.grid(column=0, row=0)
> btn_prev.grid(column=1,  row=0)
> btn_next.grid(column=2,  row=0)
> btn_last.grid(column=3,  row=0)
> 
> btn_new.grid(column=4,row=0)
> btn_edit.grid(column=5,   row=0)
> btn_delete.grid(column=6, row=0)
> btn_cancel.grid(column=7, row=0)
> 
> lbl_Recs.grid(column=8,   row=0, padx=5)
> lbl_RCount.grid(column=9, row=0, padx=5)
> btn_print.grid(column=10, row=0)
> btn_help.grid(column=11,  row=0)
> btn_save.grid(column=12,  row=0)
> 
> root.mainloop()

Hmm - this only gives me an empty window (no errors). 
What puzzles me that every book/site on tkinter strongly warns of mixing pack 
and grid managers...

Any ideas?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter spacing

2016-01-26 Thread high5storage
On Monday, January 25, 2016 at 7:41:57 PM UTC-8, KP wrote:
> If I want to have some space between, say, btn_last & btn_new, will I have to 
> use a dummy label in between these two or is there a better way?
> 
> Thanks for any help, as always!
> 
> 
> 
> 
> from tkinter import *
> from tkinter import ttk
> 
> root = Tk()
> root.geometry("822x600+100+100")
> nav_bar = ttk.Frame(root, borderwidth=2, relief='ridge', padding=(10, 3, 10, 
> 3))
> 
> btn_first  = ttk.Button(nav_bar, text='|<', width=4)  # for buttons showing 
> text only, this will be text units (= average characters?)
> btn_prev   = ttk.Button(nav_bar, text='<',  width=4)  # for image buttons, it 
> will be in pixels 
> btn_next   = ttk.Button(nav_bar, text='>',  width=4)
> btn_last   = ttk.Button(nav_bar, text='>|', width=4)
> btn_new= ttk.Button(nav_bar, text='New')
> btn_edit   = ttk.Button(nav_bar, text='Edit')
> btn_delete = ttk.Button(nav_bar, text='Delete')
> btn_cancel = ttk.Button(nav_bar, text='Cancel')
> btn_print  = ttk.Button(nav_bar, text='Print')
> btn_help   = ttk.Button(nav_bar, text='Help')
> btn_save   = ttk.Button(nav_bar, text='Save')
> lbl_Recs   = ttk.Label(nav_bar,  text='Records')
> lbl_RCount = ttk.Label(nav_bar,  text='0 ', width=10, borderwidth=2, 
> relief='sunken', anchor='e')  # fake entry look
> 
> nav_bar.grid(column=0, row=0, columnspan=13)
> 
> btn_first.grid(column=0, row=0)
> btn_prev.grid(column=1,  row=0)
> btn_next.grid(column=2,  row=0)
> btn_last.grid(column=3,  row=0)
> 
> btn_new.grid(column=4,row=0)
> btn_edit.grid(column=5,   row=0)
> btn_delete.grid(column=6, row=0)
> btn_cancel.grid(column=7, row=0)
> 
> lbl_Recs.grid(column=8,   row=0, padx=5)
> lbl_RCount.grid(column=9, row=0, padx=5)
> btn_print.grid(column=10, row=0)
> btn_help.grid(column=11,  row=0)
> btn_save.grid(column=12,  row=0)
> 
> root.mainloop()

Ah - that clears it up. Thanks for your help!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Image rotation issue

2015-03-30 Thread high5storage
On Monday, 30 March 2015 16:48:08 UTC-7, Chris Angelico  wrote:
> On Tue, Mar 31, 2015 at 8:22 AM,   wrote:
> > rotimg = img.rotate(270) # rotation is counterclockwise
> 
> Unless the 90 and 270 cases are documented as being handled specially,
> I'd look for a dedicated function for doing those changes. A quick
> perusal of the docs showed up this:
> 
> http://pillow.readthedocs.org/en/latest/reference/Image.html#PIL.Image.Image.transpose
> 
> Is that any better, or is that doing the exact same thing as rotate()?
> 
> By the way:
> 
> > The black & white only device (1024 (X) x 1280 (Y)) expects the compressed 
> > data based on portrait mode, i.e. 8 pixels combined into one bytes for 1280 
> > rows of 128 bytes.
> >
> 
> This sounds to me like the fax standard. I wonder, can you make use of
> a TIFF library to do some of your work for you?
> 
> ChrisA

According to the docs rotate & transform can both be used and should do the 
same in my case - but they are not.

rotimg = img.transpose(Image.ROTATE_270) 
print img.getbbox()
print rotimg.getbbox()

gives

(0, 0, 1280, 1024)
(0, 0, 1024, 1280)

while

rotimg = img.rotate(270, 0, 1)
print img.getbbox()
print rotimg.getbbox()

gives

(0, 0, 1280, 1024)
(1, 1, 1025, 1281)

Neither one produces good output when the compression is applied. 

Don't think it's related to fax standards - it's proprietary (E-Ink Tile)
-- 
https://mail.python.org/mailman/listinfo/python-list