It's from times ago

Status icon in C (GTK+)




#include
void tray_icon_on_click(GtkStatusIcon *status_icon,
gpointer user_data)
{
printf("Clicked on tray icon\n");
}

void tray_icon_on_menu(GtkStatusIcon *status_icon, guint button,
guint activate_time, gpointer user_data)
{
printf("Popup menu\n");
}

static GtkStatusIcon *create_tray_icon() {
GtkStatusIcon *tray_icon;

tray_icon = gtk_status_icon_new();
g_signal_connect(G_OBJECT(tray_icon), "activate",
G_CALLBACK(tray_icon_on_click), NULL);
g_signal_connect(G_OBJECT(tray_icon),
"popup-menu",
G_CALLBACK(tray_icon_on_menu), NULL);
gtk_status_icon_set_from_icon_name(tray_icon,
GTK_STOCK_MEDIA_STOP);
gtk_status_icon_set_tooltip(tray_icon,
"Example Tray Icon");
gtk_status_icon_set_visible(tray_icon, TRUE);

return tray_icon;
}

int main(int argc, char **argv) {
GtkStatusIcon *tray_icon;

gtk_init(&argc, &argv);
tray_icon = create_tray_icon();
gtk_main();

return 0;
}

Maxwell.py - eletrocmagnetism and Python

Hi folks, I get back with the blog. I brought here a code that I wrote in 2009, December. I was fascinated by the electromagnetism and I wanted to try some lib to plot graphics in python.

So I do a small program that calcule the eletric force in a spire inside a magnetic fiel that grows with a 2º grade polynomial.
This was wrote in the Tkinter GUI. See some screenshots:




Now see the code:

#! /usr/bin/env python
from pylab import *
from Tkinter import *
import tkMessageBox

class GuiFramework(Frame):
def __init__(self, master=None):
Frame.__init__(self,master)
self.master.title("Maxwell.py")
self.grid(padx=10,pady=10)
self.CreateWidgets()
def CreateWidgets(self):
self.a = Label(self, text="A:")
self.a.grid(row=0, column=0)
self.b = Label(self, text="B:")
self.b.grid(row=1, column=0)
self.t = Label(self, text="T:")
self.t.grid(row=2, column=0)
self.ra = Entry(self)
self.ra.grid(row=0, column=1, columnspan=3)
self.rb = Entry(self)
self.rb.grid(row=1, column=1, columnspan=3)
self.rt = Entry(self)
self.rt.grid(row=2, column=1, columnspan=3)
self.btn = Button(self, text="Calcule", command=self.Calcule)
self.btn.grid(row=2, column=4)
self.plot = Button(self, text="Plot", command=self.Plot)
self.plot.grid(row=0, column=4)

def Calcule(self):
r = 2*int(self.ra.get())*int(self.rt.get()) + int(self.rb.get())
tkMessageBox.showinfo("Text", "Eletric Force: %d" % r)

def Plot(self):
t = arange(0.0, 10.0, 0.01)
s = 2*int(self.ra.get())*t + int(self.rb.get())
plot(t, s, linewidth=1.0)
title('F(t)= 2.t.A + B')
grid(True)
show()

if __name__ == "__main__":
print "\n \n Maxwell will go calculate the eletric force necessary to put a ring in equillibrium second the Faraday/Lenz law. The magnetic flow grow with a polinomiun equation:\n\n at^2 + bt + c "
guiFrame = GuiFramework()
guiFrame.mainloop()

Draws? Correct

Today I watch some draws of the movie "The Wall", they was make by the
Gerald Scarf, he's married with the (beauty) Jane Asher. So I resolve to do some cartoons to enjoy me, I was drawing in a minutes before, see the results:

This is inspired in the engineering: mechanical, computing, civil, chemistry etc.



This was inspired by the Dexter's Laboratory, there are common people and genius, and the genius are not colorful by one color.

LCD number walking in Qtruby


Yes, I'm using E17

"All the people, so many people, they all go hand in hand, hand in hand through their parklife "
Blur - Parklife

Yes, I writed the LCD Number walking for the QtRuby, let see the code:
require 'Qt4'
class All < Qt::Widget
def initialize()
super()
setFixedSize(120, 250)
lcd = Qt::LCDNumber.new(2)
slider = Qt::Slider.new(Qt::Horizontal)
slider.setRange(0, 99)
slider.setValue(0)

connect(slider, SIGNAL('valueChanged(int)'), lcd, SLOT('display(int)'))
layout = Qt::VBoxLayout.new()
layout.addWidget(lcd)
layout.addWidget(slider)
setLayout(layout)
end
end

app = Qt::Application.new(ARGV)
widget = All.new()
widget.show()
app.exec()

LCD Number walking in PyQt

It's just this:



Yes, I'm using the Window Maker and I'm loving it


Now the code:

#!/usr/bin/python
import sys
from PyQt4 import QtGui, QtCore

class SigSlot(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
self.setWindowTitle('Number')
lcd = QtGui.QLCDNumber(self)
slider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
vbox = QtGui.QVBoxLayout()
vbox.addWidget(lcd)
vbox.addWidget(slider)
self.setLayout(vbox)
self.connect(slider, QtCore.SIGNAL('valueChanged(int)'), lcd, QtCore.SLOT('display(int)'))
self.resize(250, 150)

app = QtGui.QApplication(sys.argv)
qb = SigSlot()
qb.show()
sys.exit(app.exec_())

Shoegaze Player!! It's only a experience

Well!
Today I finish a very small project, I created a audio player with Python, Qt4 and the Gstreamer.
So, look a screenshot:

Yes, I'm using GNOME

It's very simple, you white the directory from the music and click in the button play to play(logic =P)

The source is here:

#!/usr/bin/python
#Writed by Carlos Junior Felix Rodrigues in GPL v 2.0

import sys
from PyQt4 import QtGui, QtCore
import gst

player = gst.Pipeline('player')
playbin = gst.element_factory_make('playbin')
player.add(playbin)

class MainWindow(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.resize(355, 30)
self.setWindowIcon(QtGui.QIcon('images/ico.svg'))
self.setWindowTitle('Shoegaze Player')
self.lineedit = QtGui.QLineEdit(self)
self.lineedit.move(100, 5)
self.lineedit.resize(250, 25)
self.play = QtGui.QAction(QtGui.QIcon('images/play'), 'Play', self)
self.stop = QtGui.QAction(QtGui.QIcon('images/stop'), 'Stop', self)
self.play.setShortcut('Ctrl+P')
QtCore.QObject.connect(self.play, QtCore.SIGNAL("triggered()"), self.on_play_clicked)
QtCore.QObject.connect(self.stop, QtCore.SIGNAL("triggered()"), self.on_stop_clicked)
self.toolbar = self.addToolBar('Play')
self.toolbar.addAction(self.play)
self.toolbar.addAction(self.stop)

def on_play_clicked(self):
player.set_state(gst.STATE_PLAYING)
playbin.set_property('uri','file:///'+ self.lineedit.displayText())

def on_stop_clicked(self):
player.set_state(gst.STATE_NULL)

if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
main = MainWindow()
main.show()
sys.exit(app.exec_())




Sorry but the buttons I can't post here, I promise to create a package with the icons.

I learned PyQt here:
http://www.zetcode.com/tutorials/pyqt4/
and
here:
http://www.learningpython.com/2008/09/20/an-introduction-to-pyqt/

It's a great advance in my mind. Thank for all the people that help me writing articles!
Remenbering, the player is opensource(GPL 2.0). You can use, edit and redistribute

Popscene Alright! =D

In a little while:

>>> x = " OI "
>>> x.replace("\00", "").strip()
'OI'
>>> print "END"
END
>>>