Skip to main content

Ralsina.Me — Roberto Alsina's website

Posts about python (old posts, page 43)

Blogging from LatinoWare

Just fin­ished speak­ing about PyQt pro­gram­ming in Lati­noWare.

It went ok, but I ran out of time, so no Q&A, and I could­n't show about 20% of the code. :-(

Any­way, here is the code in its dif­fer­ent stages, so you can see the "evo­lu­tion" of a sim­ple PyQt ap­p. I will prob­a­bly turn it in­to a re­al tu­to­ri­al in a few days and post it.

Here is the guide I was us­ing for my­self when do­ing the pre­sen­ta­tion:

    1. App back­­­end (1/­­to­­­do.py)

    2. Ba­sic win­­­dow with a treewid­get Col­umns Task/­­­Date/­­­Tags

    3. Com­pile archi­­­vo .ui, show how it works

    4. Tem­­­plate for main.py

    1. Load back­­­end da­­­ta in the task list

    2. Show in­­­ter­ac­­­tion is bro­ken

    1. Ex­­­plain sig­­­nal­s/s­lots

    2. Show dif­fer­­­ence be­tween 1/­­­main.py 2/­­­main.py

    3. Ex­­­plain au­­­to­­­con­nec­t, show on_lis­­­ta_item­Changed

    4. Show task per­­­sis­­­tence work­ing

    1. Fix tree dec­o­ra­­­tions

    2. Make items ed­itable

    3. Ex­­­plain changes in on_lis­­­ta_item­Changed

    4. Ex­­­plain the prob­lem with ed­it­ing date and tags in­­­­­line

    5. New idea: use a di­a­log to ed­it tasks (ed­i­­­tor.ui)

    6. Ex­­­plain lay­out man­agers

    1. Show changes in main.py

    1. Ac­­­tions

    2. Show ac­­­tions in de­sign­er

    3. Show ac­­­tions in main.py

    1. Tray

    2. Show tray class in main.py

    3. Show tray be­hav­iour

    4. Show dif­fer­­­ences in main.py

rst2pdf: presentations

I have been think­ing about us­ing rst2pdf to cre­ate pre­sen­ta­tion­s. I fin­ished ex­pos­ing PDF tran­si­tions to­day, and that part works nice­ly.

Still need­ed:

  • Some sort of "page dec­o­ra­­tion" fea­­ture.

  • Hand­out sup­­port? I think this would work nice­­ly with some sort of "con­di­­tion­al" di­rec­­tive. I need to think about it some more.

I in­tend to have that done for next fri­day, and re­lease then.

Programming and Life plans.

First a huge an­nounce­men­t: I will not re­lease any­thing to­mor­row. For the first time in 6 week­s, no fri­day re­lease from me!

Now, let's see what I'm plan­ning.

  1. I will be at Lati­noWare 2008 speak­ing about PyQt. The usu­al free beer of­fer: if you men­­tion this blog, I will buy you 1 (one) not very good beer. Be­ing in Brazil, that's prob­a­bly a Brah­­ma.

  2. rst2pdf de­vel­op­­ment is slow­ing down. The easy stuff is all done. There are some things I can do, though:

    • Ex­­­pose tran­si­­­tions to the writ­er (good for pre­sen­­­ta­­­tion­s)

    • "Back­­­­­ground" forms (a­­­gain, for pre­sen­­­ta­­­tion­s)

    • A mini-lan­guage ex­­­pos­ing the can­­­vas, so there is a use­­­ful "raw" mod­­­e.

    • Us­ing svglib in­­­stead of uni­­­con­ver­­­tor to han­­­dle SVG (but keep uni­­­con­ver­­­tor for oth­­­er vec­­­tor for­­­mat­s)

    • Re­­­do­ing list­s, which have a shaky code and bad lay­out

    • Fix half a dozen bugs

    • Make it work more like a unix app when in unix (re­spect en­vi­ron­­­ment vars, for ex­am­­­ple)

    How­ev­er, I am tak­ing a lit­­tle time off from it, and go­ing to try re­­viv­ing oth­­er pro­jec­t­s. Fo­­cus­ing in rst2pdf for two months did won­ders for it. Let's see if it can be re­­peat­ed!

  3. Try some more code golf­ing. I helped Nu­bis from PyAr reach the low­est­-s­­core of 74 in the grid chal­lenge. This is re­al­­ly fun stuff.

  4. I need more mon­ey. We have spent lots in ... plumb­ing. Yup. Two years of sav­ings spent on that. So, I need mon­ey. If you read this blog and want to make me hap­py, get me free­lance work. It can be sysad­min stuff, it can be pro­­gram­ming, it can be babysit­t­ing. I am good at all three things. Con­­tact me. I'm easy to find, and I am cheap­­(ish).

  5. No, I am not starv­ing. No, I am not in mon­ey prob­lem­s. Yes, my com­­pa­ny is do­ing very well, but it's an in­­vest­­men­t, not a cash cow (yet).

Golfing

I spent a few hours to­day round Code Golf and here's a neat thing I did.I think this is python's short­est pos­si­ble fac­to­ri­al:

f=lambda x:x<2or x*f(x-1)

You may say it's not cor­rec­t, be­cause f(1) re­turns True, but in­t(True) is 1, so it's al­most there ;-)

And here's a sur­pris­ing­ly read­able (as long as you know pas­cal's tri­an­gle) and not too long an­swer to their choose chal­lenge:

n,k=input()
a,c=1,0
while c<k:a*=n-c;c+=1;a/=c
print a

Contents © 2000-2020 Roberto Alsina