Skip to content

Posts from the ‘Python’ Category

11
Feb

PyQt: How to hide top level nodes in tree view

In Qt treeview, hidding top level nodes is different to hidding lower level nodes. Lets start with a simple treeview example with two non-empty branches. Here is the code:
Read more »

2
Oct

Styling Qt QTreeView with CSS

Qt offers additional CSS settings such as sub-control and pseudo-states. Although there are reference and brief tutorial with examples, it doesn’t really show how this settings affect the overall look. In this article, we explore how to style the QTreeView via CSS in step by step. First of all, we use a simple treeview directory program (Python/Qt5 ) from this example and style it gradually.
Read more »

23
Sep

List of Qt Icons

I was given a job to smarten up a GUI program which is implemented in PyQt. One of the tasks is to put up some icons in the user interface. I know that Qt includes it’s own set of icons. However, I can’t find any page online showing what these icons look like. So I wrote a little program to list all the available Qt icons. Here is the screenshot:

List of Qt icons
Read more »

30
Jun

Python 3: __del__ method and imported modules

My python script generates the following error and the strange thing is that this error only occurs occasionally:

Exception AttributeError: "'NoneType' object has no attribute 'path'" in 
<bound method Client.__del__ of <__main__.MyObject object at 0x108c3dc50>> ignored

Read more »

14
Apr

How to send & receive serialized simple objects across PHP & Python? Of course! JSON

I hacked a client & server PHP programs for part of a demo. However, the notorious memory intensive PHP makes my server process swallowing so much memory (the size of sample data and lots of associative arrays) to a point that is impractical to run. So I decided to bite the bullet to port the server side into Python. Then it was fine until it hit me, “How is the PHP client going to talk to Python server side?” Read more »

9
Jul

Example of using Python to logon & access Ajax (JSON) webpage in the background

We have an application written in PyGtk. Recently, we need to modify the application to access one of our AJAX/JSON webpages in the background. The beauty of AJAX/JSON webpages opens a channel for any applications to easily access the content. Especially for LAMP product, this avoids directly connecting to the database and using specific SQL queries. As long as the webpages are constructed in AJAX/JSON, then the Python cjson or json package can parse the returned JSON result into a dictionary object. Read more »