Skip to main content

Ralsina.Me — Roberto Alsina's website

Posts about programming (old posts, page 30)

Text-based presentations

There have been a few posts on plan­et KDE about tex­t-based pre­sen­ta­tion tools (1 , 2 , 3) and while their so­lu­tions are all prob­a­bly bet­ter than mine, I have to say I did some­thing in the area about a year ago.

Since I like re­struc­tured text and PyQt that's what it's based on, but you can just use it with vi and a wyse60, if you wan­t.

My project is called To­bo­gan and it has a work­ing ver­sion.

It has a GUI, but let's ig­nore it for this post about tex­t-based soft­ware ;-) and show the text be­hind it:

===============
Why use Tobogan
===============

-------------------
(If you are a nerd)
-------------------

:transitions: from_left,to_left,from_top,to_top,from_right,to_right,to_bottom,fade_out



It's nerd-oriented
------------------

It's trivial to display source code, with
proper syntax highlighting.

.. code-block:: python

    from base64 import *
    def myFirstFunction():
          print b64decode ('YnllIHdvcmxkIQ==')

Even for things like shell sessions.
Dammit, I am a nerd, I will try to add every nerd
feature I deem cool.



It does things simply
---------------------

This is a subtitle?
===================

Wanna show a flickr photo?

.. code-block:: rst

    .. flickr:: myPhotoTitle

How about using openomy.com to share your files?
And whatever else you can think of, it probably
**can**\  be done.

.. footer:: Smart thing goes here

And here is the re­sult af­ter run­ning rst2s­l.py on it.

Hints:

  • If you move the cur­­sor to the top, you will get (bro­ken?) pre­vi­ous/next ar­rows

  • If you click on the win­­dow, you get to the next slide.

I have not touched this in al­most a year, and it would need lots of love, but it's not a bad con­cep­t, IMVHO.

Open with: Google Docs

The eee is smal­l. It has very lit­tle stor­age. So, why should I use dozens of MB on a word pro­ces­sor? Be­cause I get word doc­u­ments in the mail ev­ery once in a while.

In fac­t, the on­ly word doc­u­ments I get are er­ror mes­sages from win­dows user­s. Here's the pro­ce­dure ev­ery one of them seems to have found to tell me what's in­side ex­plor­er's er­ror pages:

  1. Cap­­ture the screen

  2. Paste it in­­­to Word

  3. Mail it to me

I sup­pose copy­&­paste of the page con­tents was too hard. But any­way, I usu­al­ly man­age by hav­ing kword or abi­word handy, but I was think­ing...

I am reading my email. That means I am on the net. That means google docs is right there. And they have a python API! 15 minutes later... open_with_gdocs.py

#!/usr/bin/env python
import gdata.docs.service,gdata,sys,os

# Create a client class which will make HTTP requests with Google Docs server.
client = gdata.docs.service.DocsService()
# Authenticate using your Google Docs email address and password.
client.ClientLogin('joe@gmail.com', 'whateveritis')

ms = gdata.MediaSource(file_path = sys.argv[1], content_type = "application/msword")
entry = client.UploadDocument(ms,"tmp_open_with_gdocs/%s"%sys.argv[1])
os.system("firefox '%s'"%entry.GetAlternateLink().href)

Try it, as long as you have fire­fox, a de­cent ver­sion of python and gda­ta it should open the doc you pass as first ar­gu­ment on google docs in fire­fox.

Re­mem­ber that you need to delete it lat­er if you don't want it, and re­name it if you want to keep it with a de­cent name.

I am not turn­ing it in­to a re­al ap­p, but it's good enough for me. Put it in your path and as­so­ciate it to your .doc files.

A sim­i­lar thing for .xls is triv­ial. A script that would han­dle both, al­so.

Could please some­one take this and make it a re­al ap­p?

rst2pdf: New and improved

My rst2pdf script has had sev­er­al things hap­pen to it.

  1. It got an­oth­er guy work­ing on it: Christoph Zw­er­schke

  2. It's on google­­code now: http://rst2pdf.­­google­­code.org

  3. Christoph made a num­ber of im­prove­­ments:

    • bul­let­ed and enu­mer­at­ed list sim­­­pli­­­fied, use same font as text for bul­lets and num­bers

    • links in ta­ble of con­­­tents work

    • com­­­press lit­er­al sec­­­tions hor­i­­­zon­­­tal­­­ly so that they al­ways fit on the page

  4. I have in­­te­­grat­ed hy­phen­a­tion us­ing wor­­daxe (works on­­ly with re­­port­lab 2.1)

The out­put us­ing hy­phen­ation is re­al­ly ug­ly right now (for ex­am­ple, I get a black square in­stead of an hy­phen) but it's a small step for­ward.

Rebelling against insanity: Wicd requires half of GNOME

UP­DATE: you can get this pro­gram now at google code

I have been us­ing my eee for a while al­ready with a sort of Kubun­tu in it.

How­ev­er, my favourite wire­less/wired net­work man­age­ment app is wicd, which is a Python/GTK ap­pli­ca­tion. Or was, since ver­sion 1.4.1 re­quires python-g­nome2-ex­tras.

Which de­pends on ....

libart-2.0-2 (>= 2.3.18), libaspell15 (>= 0.60), libatk1.0-0 (>= 1.13.2), libbonobo2-0 (>= 2.15.0),
libbonoboui2-0 (>= 2.15.1), libc6 (>= 2.6-1), libcairo2 (>= 1.4.0),
libfontconfig1 (>= 2.4.0), libfreetype6 (>= 2.3.5), libgconf2-4 (>= 2.13.5),
libgda3-3, libgdl-1-0, libgdl-gnome-1-0, libgksu1.2-1 (>= 1.3.3), libgksu2-0 (>= 1.9.6),
libgksuui1.0-1, libglade2-0 (>= 1:2.6.1), libglib2.0-0 (>= 2.14.0), libgnome-keyring0 (>= 2.19.6),
libgnome2-0 (>= 2.17.3), libgnomecanvas2-0 (>= 2.11.1), libgnomeui-0 (>= 2.19.1),
libgnomevfs2-0 (>= 1:2.17.90), libgtk2.0-0 (>= 2.12.0), libgtkspell0 (>= 2.0.2),
libice6 (>= 1:1.0.0), libnspr4-0d (>= 1.8.0.10), liborbit2 (>= 1:2.14.8),
libpango1.0-0 (>= 1.18.2), libpng12-0 (>= 1.2.13-4), libpopt0 (>= 1.10), libsm6,
libstartup-notification0 (>= 0.8-1), libx11-6, libxcomposite1 (>=1:0.3-1),
libxcursor1 (>> 1.1.2), libxdamage1 (>= 1:1.1), libxext6, libxfixes3 (>= 1:4.0.1), libxi6, libxinerama1,
libxml2 (>= 2.6.29), libxrandr2 (>= 2:1.2.0), libxrender1, zlib1g (>= 1:1.2.3.3.dfsg-1),
python-support (>= 0.3.4), python (<< 2.6), python (>= 2.4), python-gtk2,
python-pyorbit, python-gnome2-desktop

In short: a 87MB down­load. That can't be good. In fac­t, there are al­most no changes from 1.3.1 which did­n't re­quire all that! Ex­cept for one change that makes all the dif­fer­ence on a eee PC: ver­ti­cal re­siz­ing to un­der 400px. :-(

So, be­cause I am who I am, I did this:

wicd-qt.png

It's a re­place­ment for wicd's gui.py and tray.py. On­ly needs PyQt4 which I al­ready had and de­pends on:

libc6 (>= 2.6-1), libgcc1 (>= 1:4.2.1), libqt4-core (>= 4.3.2),
libqt4-gui (>= 4.3.2), libstdc++6 (>= 4.2.1), python-central (>= 0.5.8),
python (<< 2.6), python (>= 2.4), python-sip4 (>= 4.7), python-sip4 (<< 4.8)

See a dif­fer­ence there?

Took me about 3 hours to hack to­geth­er, and works (ex­cept for wired con­fig, the prefs di­alog, stat­ic IP and script­s) but the hard work is done.

If any­one wants a copy, just ask. I ex­pect KUbun­tu could use some­thing like it?

Thinking in 800x480: Web browsing

I am still anx­ious­ly wait­ing for my Asus eee (still a week to go or so), and I was think­ing about web brows­ing in the 7", 800x480 screen.

Yes, you can do the usu­al things, go to full screen mod­e, what­ev­er, but for many sites, 800 pix­els is just too nar­row.

You can make pages fit bet­ter in a lim­it­ed width by re­duc­ing the font size. A good 8pt font is prob­a­bly read­able on that screen, since you will be pret­ty close to the screen.

How­ev­er, that does noth­ing for lay­outs that are pix­el-based, and for the size of im­ages.

How­ev­er, af­ter read­ing about Qt 4.4's sup­port for we­bkit and wid­gets in QGraph­icsView, I start­ed think­ing... that's do­ing it wrong.

What you want in lim­it­ed screen space is text in the usu­al size and the page in a small­er size.

So, my idea is:

  • Make the font larg­er. Say, 12p­t.

  • Ren­der the page in a we­bkit wid­get that's 1200x720 pix­el­s.

  • Put the wid­get in a QGraph­ic­sS­cene, and re­­duce it 33%.

The re­sult? a 800x480 web page view that con­tains the whole page.

Of course you should be able to change all these pa­ram­e­ters with a sin­gle con­trol. Is the page too wide to see in 800x480 with 8pt fonts?

Then try 1000x600 with 10pt fonts, and re­duce it to fit the screen.

Still too wide? Then try 1200x720 and a 33% re­duc­tion.

Pos­si­ble tip­s:

  • Should work bet­ter with aliased fonts, since the size re­­duc­­tion should make an­­tialiased fonts too blur­ry. A wide, open font will look bet­ter,

  • The scrol­l­bars will look squashed, I ex­pec­t. Prob­a­bly check­­box­es and ra­­dio but­­tons will look funky. Here, more ad­­vanced wiz­­ardry is need­ed.

Of course it would have to be test­ed, but I am will­ing to bet this will work bet­ter than oth­er al­ter­na­tives. If I had a work­ing PyQt 4.4 I would try to do it my­self ;-)


Contents © 2000-2024 Roberto Alsina