background preloader

Python

Facebook Twitter

Introduction to PyQt4. Home > Python and PyQt4 > Introduction to PyQt4 Creating an application in PyQT4 may be done in a few ways. The most common one is to use QTDesigner, which we get with QT. QTDesigner let us draw the GUI which is very handy for complicated interfaces. We can place widgets on the window, add names etc. To create an application in PyQT4 you have to: Create the GUI in QTDesignerSet names in the Property Editor to ease coding of the application (QTDesigner)Using pyuic4 create the python GUI classCall the application using that GUI classExtend it with our own slotsWhen you use a widget you go to PyQt's Classes and check methods of each used widgets.

The method names as "setText" are very easy to understand. Tutorials List Introduction We start with a "Hello... We choose simple Widget, which will give us a simple window. Right-Click on the pushButton will allow us to change its caption (displayed text). A Signal-Slots window should appear: The signal is clicked() and slot is close. And run it: Notes. Nathan Horne – Technical Artist » PyQt and Maya 2011. Re-posting some information here that I had posted on TD club: Here’s a quick little bit of code showing how to create a custom GUI class using pyqt (Almost all the pyqt examples use this over using some form of .ui file, because it allows for much more control).

You can also use it in combination with ui files thanks to pyqt’s uic module. QT does not require objects to have “names”, but if you ever want to find your pyqt objects using MQtUil.findControl then you need to assign it a name using OBJECT.setObjectName(“AwesomeWindow”). In the above example, in the MayaSubWindow. __init__ function you would call self.setObjectName(“AwesomeWindow”). Also, since qt does not require names, it also does not require that control names be unique, so it’s completely possible to use findControl and get the “wrong” object.

Here’s a pyqt example using uic to load in a ui file (Rather than maya’s new loadUi command, which wont give you all your pyqt objects. Designer .UI file. First programs in PyQt4 toolkit. HomeContents In this part of the PyQt4 tutorial we will learn some basic functionality. Simple example This is a simple example showing a small window. Yet we can do a lot with this window. We can resize it, maximize it or minimize it. . #! The above code shows a small window on the screen. import sys from PyQt4 import QtGui Here we provide the necessary imports. App = QtGui.QApplication(sys.argv) Every PyQt4 application must create an application object. W = QtGui.QWidget() The QtGui.QWidget widget is the base class of all user interface objects in PyQt4. W.resize(250, 150) The resize() method resizes the widget. W.move(300, 300) The move() method moves the widget to a position on the screen at x=300, y=300 coordinates. w.setWindowTitle('Simple') Here we set the title for our window.

W.show() The show() method displays the widget on the screen. Sys.exit(app.exec_()) Finally, we enter the mainloop of the application. The exec_() method has an underscore. Figure: Simple An application icon #! Figure: Icon. Javascript game of tron in 219 bytes. With some coworkers, we challenged each other to write the smallest possible game of tron in javascript (an exercise known as javascript golfing).

This page explains our final version (219 bytes). We initially worked alone but then exchanged ideas and tricks, so erling & mathewsb deserve most of the credits! Our code was originally 226 bytes, but "Cosmologicon" pointed out a way to save three whole bytes, bringing us to 223 bytes. With p01, we then came up with a way to save another 11 bytes (making the game 212 bytes). He also suggested keeping track of score, which takes 9 bytes but is totally worth it!

Skrounge found a way to save 2 more bytes, bringing the game to 219 bytes. Danny Loo sent me this piece of art. The entire code, with only a few extra newlines for readability. By assigning an id to the body, we are going to be able to write b.innerHTML="game over", instead of having to write document.body.innerHTML="game over"*. We use onkeyup instead of onkeydown, since it saves 2 bytes.

9.8. functools — Higher-order functions and operations on callable objects — Python v2.7.2 documentation. Source code: Lib/functools.py The functools module is for higher-order functions: functions that act on or return other functions. In general, any callable object can be treated as a function for the purposes of this module. The functools module defines the following functions: functools.cmp_to_key(func) Transform an old-style comparison function to a key function. A comparison function is any callable that accept two arguments, compares them, and returns a negative number for less-than, zero for equality, or a positive number for greater-than.

Example: sorted(iterable, key=cmp_to_key(locale.strcoll)) # locale-aware sort order For sorting examples and a brief sorting tutorial, see Sorting HOW TO. functools.total_ordering(cls) Given a class defining one or more rich comparison ordering methods, this class decorator supplies the rest. The class must define one of __lt__(), __le__(), __gt__(), or __ge__().

For example: functools.reduce(function, iterable[, initializer]) partial.func partial.args. Mediawiki-parser/parsers.rst at master · erikrose/mediawiki-parser. Essential Python Reading List. Here’s my essential Python reading list. I’ve tried to order the items so you can pause or stop reading at any point: at every stage you’ll have learned about as much possible about Python for the effort you’ve put in. The Zen of Python The Zen of Python is so short I can include it here in its entirety. Typing import this in an interpreted session gives a pythonic spin on “Hello, world”. >>> import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. If this doesn’t ring true, Python isn’t for you. Python Tutorial Your next stop should be the Python tutorial.

Start here And with this tutorial, you’ll be running code right from the start. Since the best way to learn a language is to use it, the tutorial invites you to play with the Python interpreter as you read. A tutorial cannot cover everything, of course, and this one recognises that and points you towards further reading. Python Library Reference What’s New? Python functional programming for mathematicians « mvngu. This tutorial discusses some techniques of functional programming that might be of interest to mathematicians or people who use Python for scientific computation.

We first start off with a brief overview of procedural and object-oriented programming, and then discuss functional programming techniques. Along the way, we briefly review Python’s built-in support for functional programming, including filter(), lambda, map() and reduce(). The tutorial concludes with some resources on detailed information on functional programming using Python. Styles of programming Python supports several styles of programming. Another common style of programming is called object-oriented programming.

Functional programming using map() Functional programming is yet another style of programming in which a program is decomposed into various functions. Takes a function func and one or more sequences, and apply func to elements of those sequences. Define small functions using lambda Reducing a sequence to a value. The igraph library for complex network research. NodeBox. NodeBox is a Mac OS X open-source application for creating 2D visual output (static or animated) using Python programming language. The application targets an audience of designers, with an easy set of state commands that is both intuitive and creative. It is essentially a learning environment and an automation tool. NodeBox also allows PDF and Quicktime export, as well as importing vector files from Adobe Illustrator.

NodeBox is based on DrawBot 0.9a (DrawBot is a project initiated by Just Van Rossum from LettError, a simple MacOSX application that allows you to write Python scripts that generate two-dimensional graphics). NodeBox is being developed by Frederik De Bleser (frederik@pandora.be). NodeBox is a "state machine". Thumbnail gallery. Computational Legal Studies™ | Computational Legal Studies™ Programming Dynamic Models in Python. In this series of tutorials, we are going to focus on the theory and implementation of transmission models in some kind of population. In epidemiology, it is common to model the transmission of a pathogen from one person to another. In the social sciences and law, we may be interested in thinking about the way in which individuals influence each other’s opinions, ideology and actions.

These two examples are different, but in many ways analogous: it is not difficult to imagine the influence that one individual has on another as being similar to the infectivity of a virus in the sense that both have the ability to change the state of an individual. One may go from being susceptible to being infected, or from unconvinced to convinced.

Additionally, social networks have become an important area of study for epidemiological modelers. Model Assumptions 1. Before getting into the mechanics of the model, let’s talk about the theory and assumptions behind the model as it is implemented here: 2. 3.

Houdini Python GUI

Buy Komodo IDE 6 | ActiveState Store. <div id="as_noscript"> You appear to have turned off javascript in your browser. Please turn javascript back on in order to proceed smoothly through our store. Thank you. </div> Professional IDE for Python, PHP, Ruby, Perl and Web Dev (HTML, CSS, JavaScript). Installers for Windows, Mac and Linux. Komodo IDE has per user licensing: a single license covers the same user across all supported platforms. "If you work in any of the languages Komodo supports, you owe it to yourself to examine it (for free). Limited Time Only! *Restrictions apply. Single License including Upgrades and Support* Includes technical support and all upgrades while your subscription is current. 5-Pack including Upgrades and Support* Save with a 5-pack!

Ctypes tutorial. Note: The code samples in this tutorial uses doctest to make sure that they actually work. Since some code samples behave differently under Linux, Windows, or Mac OS X, they contain doctest directives in comments. Note: Quite some code samples references the ctypes c_int type. This type is an alias to the c_long type on 32-bit systems. So, you should not be confused if c_long is printed if you would expect c_int - they are actually the same type. ctypes exports the cdll, and on Windows also windll and oledll objects to load dynamic link libraries. You load libraries by accessing them as attributes of these objects. cdll loads libraries which export functions using the standard cdecl calling convention, while windll libraries call functions using the stdcall calling convention. oledll also uses the stdcall calling convention, and assumes the functions return a Windows HRESULT error code.

Windows appends the usual '.dll' file suffix automatically. >>> getattr(cdll.msvcrt, "?? >>> pi[0] 99 >>>