Nano'nun Günlüğü…

Ideallerimi gerceklestirmek icin arastiriyorum, Unutmamak icin yaziyorum!

  • Bulundugunuz Sayfa: 
  • Ana Sayfa
  • Python Egitim Notlari – VI

Python Egitim Notlari – VI

Gönderim Ocak 27th, 2013

Egitimin altinci adiminda, Python’da gorsel uygulamalar icin ornekler yapiyor olacagiz. Bunun icin belirli dizin yapilari olusturup icerilerine kullanacagimiz siniflari ekliyor olacagiz. Ayrica ilgili Tutorial’lara, kurmus oldugunuz Python paketleri icerisindeki The Python Tutorial.html icerisinden de ulasabilirsiniz.

– Gorsel Programlama icin gerekli olan yapilar PyQt ‘dir. Kurulumu yaptiktan sonra main fonksiyonlarini kullanmaya baslayabilirsiniz;

DEGISKEN = []
def main():
a = “deneme”
print a
if __name__==”__main__”:
main()
print “deneme main”

– Ekranin ortasinda buton gorseli 1

from PyQt4 import QtGui
import sys
class GorselSinif(QtGui.QWidget):
def __init__(self):
super(GorselSinif,self).__init__()
self.ayarla()
def ayarla():
self.buton = QtGui.QPushButton(‘Tikla’,self)
self.buton.move(20,20)
self.buton.clicked.connect(self.yazdir)
self.show()
if __name__==”__main__”:
uygulama = QtGui.QApplication(sys.argv)
gorsel_nesne = GorselSinif()
sys.exit(uygulama.exec_())
def yazdir(self):
print “Butona Basildi”

– Ekranin ortasinda buton gorseli 2

from PyQt4 import QtGui
import sys
class GorselSinif(QtGui.QWidget):
def __init__(self):
super(GorselSinif,self).__init__()
self.ayarla()
def ayarla():
self.buton = QtGui.QPushButton(‘Tikla’,self)
self.buton.move(20,20)
self.buton.clicked.connect(self.yazdir)
self.metin = QtGui.QLineEdit(self)
self.metin.move(200,20)
self.metin.setText(“fkjhdjksfhfsdjk”)
self.show()
if __name__==”__main__”:
uygulama = QtGui.QApplication(sys.argv)
gorsel_nesne = GorselSinif()
sys.exit(uygulama.exec_())
def yazdir(self):
print “Butona Basildi %s” %self.metin.text()

– Ekranin ortasinda buton gorseli 3

from PyQt4 import QtGui
import sys
class GorselSinif(QtGui.QWidget):
def __init__(self):
super(GorselSinif,self).__init__()
self.ayarla()
def ayarla():
self.buton = QtGui.QPushButton(‘Tikla’,self)
self.buton.move(20,20)
self.buton.clicked.connect(self.yazdir)
self.metin = QtGui.QLineEdit(self)
self.metin.move(200,20)
self.metin.setText(“fkjhdjksfhfsdjk”)
self.show()
def yazdir(self):
metin , onay= QtGui.QInputDialog.getText(self,’Baslik’,’Adinizi Giriniz.’)
print onay
print metin
if __name__==”__main__”:
uygulama = QtGui.QApplication(sys.argv)
gorsel_nesne = GorselSinif()
sys.exit(uygulama.exec_())

– Ekranin ortasinda buton gorseli 4

from PyQt4 import QtGui
import sys
class GorselSinif(QtGui.QWidget):
def __init__(self):
super(GorselSinif,self).__init__()
self.ayarla()
def ayarla():
self.buton = QtGui.QPushButton(‘Tikla’,self)
self.buton.move(20,20)
self.buton.clicked.connect(self.yazdir)
self.metin = QtGui.QLineEdit(self)
self.metin.move(200,20)
self.metin.setText(“fkjhdjksfhfsdjk”)
self.show()
def yazdir(self):
metin , onay= QtGui.QInputDialog.getText(self,’Baslik’,’Adinizi Giriniz.’)
if onay:
self.metin.setText(metin)
if __name__==”__main__”:
uygulama = QtGui.QApplication(sys.argv)
gorsel_nesne = GorselSinif()
sys.exit(uygulama.exec_())

– Ekranin ortasinda buton gorseli 5

from PyQt4 import QtGui
import sys
class GorselSinif(QtGui.QWidget):
def __init__(self):
super(GorselSinif,self).__init__()
self.ayarla()
def ayarla():
self.buton = QtGui.QPushButton(‘Tikla’,self)
self.buton.move(20,20)
self.buton.clicked.connect(self.yazdir)
self.metin = QtGui.QLineEdit(self)
self.metin.move(200,20)
self.metin.setReadOnly(True)
self.metin.setText(“Ornek Uygulama”)
self.show()
def yazdir(self):
metin , onay= QtGui.QInputDialog.getText(self,’Baslik’,’Adinizi Giriniz.’)
if onay:
self.metin.setText(metin)
if __name__==”__main__”:
uygulama = QtGui.QApplication(sys.argv)
gorsel_nesne = GorselSinif()
sys.exit(uygulama.exec_())

IPython Kullanimi

import PyQt4. tab a basarak dizinler arasinda dolasabilirsiniz…
map? kullanimini ogtrenebiliriz..

Web Tarayici Uygulamasi

from PyQt4 import QtGui. QtCore, QtWebKit
import sys
class Tarayici(QtGui.QMainWindow):
def __init__(self):
super(Tarayici, self).__init__()
self.resize(800,600)
self.anawidget = QtGui.QWidget(self)
self.analayout = QtGui.QHBoxLayout(self.anawidget)
self.analayout.setSpacing(0)
self.analayout.setMargin(1)
self.cerceve = QtGui.QFrame(self.anawidget)
self.framelayout = QtGui.VBoxLayout(self.cerceve)
self.panellayout = QtGui.QHBoxLayout()
self.geri_buton = QtGui.QPushButton(self.cerceve)
self.ileri_buton = QtGui.QPushButton(self.cerceve)
self.web_site_metin = QtGui.QLineEdit(self.cerceve)
self.geri_buton.setIcon(QtGui.Icon().fromTheme(“go-previous”))
self.ileri_buton.setIcon(QtGui.Icon().fromTheme(“go-next”))
self.panellayout.addWidget(self.geri_buton)
self.panellayout.addWidget(self.ileri_buton)
self.panellayout.addWidget(self.web_site_metin)
self.cercevelayout.addlayout(self.panellayout)
self.tarayici = QtWebKit.QWebView()
self.cercevelayout.addWidget(self.tarayici)
self.analayout.addWidget(self,cerceve)
self.setCentralWidget(self.anawidget)
self.connect(self,geri_buton, QtCore.SIGNAL(“clicked()”),self.tarayici.back)
self.connect(self,ileri_buton, QtCore.SIGNAL(“clicked()”),self.tarayici.forward)
self.connec(self.web_site_metin, QtCore.SIGNAL(“returnPressed()”),self.git)
self.show()
def git(self):
self.tarayici.load(QtCore.QUrl(self.web_site_main.text()))
if __name__ == “__main__”:
uygulama = QtGui.QApplication(sys.argv)
tarayici = Tarayici()
sys.exit(uygulama.exec_())

Keyifli Calismalar Dilerim..

Etiketler:
Bulundugu Konu Etiketleri Python, Yazilim |

Lutfen Yorumlarinizi Burdan Ulastiriniz!...

You must be Kullanici Adiniz : to post a comment.

Istatistik

  • 1 Uye
  • 334 Yazi
  • 16 Yorum Var