Draws? Correct
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 "
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
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
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
>>> x = " OI "
>>> x.replace("\00", "").strip()
'OI'
>>> print "END"
END
>>>
RBrainz - Musicbrainz API for Ruby !
Today I've decided to test a simple API for Ruby, so I look for something in the Rubyforge.I found the Rbrainz, how the title describe, a MusicBrainz API, I really don't know what was MusicBrainz, I only know that amarok use it. I search about this in the Wikipedia. It's a music library, well I love music and Ruby, so I start to program with it. Now let's see a small tutorial:
First, download the API in the official website(http://rbrainz.rubyforge.org/) or using the gems:
gem install rbrainz
Starting our script, read the comments:
_________________________________________________________________
#/usr/bin/env ruby
require 'rubygems'
require 'rbrainz'
include MusicBrainz
#we required the dependencies
artists_includes = Webservice::ArtistIncludes.new(
:aliases=>true,
:releases=>['Album', Official'],
:artist_rels=>true,
:release_rels=>true,
:track_rels=>true,
:label_rels=>true,
:url_rels=>true,
#We created a Hash with informations
query = Webservice::Query.new
id = 'ba853904-ae25-4ebb-89d6-c44cfbd71bd2'
artista = query.get_artist_by_id(id, artist_includes)
#Variables for describe the webservice(query), the artist ID, you can see the information searching in the musicbrainz's website and we put the object called artist the id and the hash called artist_includes.
#Now we will print the informations
print < < eof
ID number(número de id):#{artista.id.uuid}
Name(nome):#{artista.name}
Begin date(data de início):#{artista.begin_date}
End date(data do fim):#{artista.end_date}
Aliases(participantes):#{artista.aliases.to_a.join('; ')}
Releases(Álbuns):#{artista.releases.to_a.join('; ')}
EOF
_________________________________________________________________
End of the script, now see the output:
ID : ba853904-ae25-4ebb-89d6-c44cfbd71bd2
Name : Blur
Begin date : 1989
End date :
Aliases : Albarn James Coxon Rowntree
Releases : Modern Life Is Rubbish; Modern Life Is Rubbish; Leisure; Leisure; Modern Life Is Rubbish; Modern Life Is Rubbish; Parklife; Parklife; Leisure; The Great Escape; The Great Escape; The Great Escape; Blur; Blur; 13; 13; Think Tank; Think Tank
Yes, ba853904-ae25-4ebb-89d6-c44cfbd71bd2is the Blur's ID
I take the ID here: http://musicbrainz.org/show/artist/details.html?artistid=361
Rock, paper, scissor... and Ruby
Well, I wrote this game in a stressed day. Ruby make me feel better.
Now, see the code:
#!/usr/bin/env ruby
#Pedra, papel, tesoura e Ruby ;D
def pedra
b = rand(3)
if b == 0
puts "Pedra, empate"
return menu()
elsif b == 1
puts "Tesoura, você ganhou"
return menu()
elsif b == 2
puts "Papel, você perdeu"
return menu()
end
end
def tesoura
b = rand(3)
if b == 0
puts "Pedra,Você perdeu"
return menu()
elsif b == 1
puts "Tesoura, empate"
return menu()
elsif b == 2
puts "Papel, você ganhou"
return menu()
end
end
def papel
b = rand(3)
if b == 0
puts "Pedra, você ganhou"
return menu()
elsif b == 1
puts "Tesoura, você perdeu"
return menu()
elsif b == 2
puts "Papel, empate"
return menu()
end
end
def menu
puts "Opcao: \n[1] Pedra \n[2] tesoura \n[3] papel \n[Qualquer numero] sair"
print ">>"
a = gets.chomp.to_i
case (a)
when 1
pedra()
when 2
tesoura()
when 3
papel()
end
end
menu()
Ruby, Gtk+ and Txt's
#!/usr/bin/env ruby
# Escrito por Carlos Junior Félix Rodrigues; Licença: GPL v2
require 'gtk2'
window = Gtk::Window.new
window.title = "Text Box"
button = Gtk::Button.new("Salvar")
text = Gtk::Entry.new
hbox = Gtk::HBox.new(false, 10)
hbox.pack_start(text)
hbox.pack_start(button)
window.add(hbox)
window.signal_connect("destroy"){Gtk.main_quit}
button.signal_connect("clicked"){
arquivo = File.new("arquivo.txt", "a")
arquivo.puts "#{text.text}"
arquivo.close
}
window.show_all
Gtk.main
See you latter