#!/usr/bin/python
import sys, time
from Tkinter import *
class Logger(Frame):
def __init__(self):
Frame.__init__(self)
self.pack(expand=YES, fill=BOTH)
self.master.title("Timestamp logging application")
self.tslist = []
self.tsdisp = Text(height=6, width=25)
self.count = StringVar()
self.cntdisp = Message(font=('Sans',24),
textvariable=self.count)
self.log = Button(text="Log Timestamp",
command=self.log_timestamp)
self.quit = Button(text="Quit", command=sys.exit)
self.tsdisp.pack(side=LEFT)
self.cntdisp.pack()
self.log.pack(side=TOP, expand=YES, fill=BOTH)
self.quit.pack(side=BOTTOM, fill=BOTH)
def log_timestamp(self):
stamp = time.ctime()
self.tsdisp.insert(END, stamp+"\n")
self.tsdisp.see(END)
self.tslist.append(stamp)
self.count.set("% 3d" % len(self.tslist))
if __name__=='__main__':
Logger().mainloop()
class StdOutLogger(Logger):
def log_timestamp(self):
Logger.log_timestamp(self)
print self.tslist[-1]
#!/usr/bin/env python
import sys, time
from qt import * # Generally advertised as safe
class Logger(QWidget):
def __init__(self, *args):
QWidget.__init__(self, *args)
self.setCaption("Timestamp logging application")
self.layout = QGridLayout(self, 3, 2, 5, 10)
self.tsdisp = QTextEdit(self)
self.tsdisp.setMinimumSize(250, 300)
self.tsdisp.setTextFormat(Qt.PlainText)
self.tscount = QLabel("", self)
self.tscount.setFont(QFont("Sans", 24))
self.log = QPushButton("&Log Timestamp", self)
self.quit = QPushButton("&Quit", self)
self.layout.addMultiCellWidget(self.tsdisp, 0, 2, 0, 0)
self.layout.addWidget(self.tscount, 0, 1)
self.layout.addWidget(self.log, 1, 1)
self.layout.addWidget(self.quit, 2, 1)
self.connect(self.log, SIGNAL("clicked()"),
self.log_timestamp)
self.connect(self.quit, SIGNAL("clicked()"),
self.close)
def log_timestamp(self):
stamp = time.ctime()
self.tsdisp.append(stamp)
self.tscount.setText(str(self.tsdisp.lines()))
if __name__ == "__main__":
app = QApplication(sys.argv)
app.connect(app, SIGNAL('lastWindowClosed()'), app,
SLOT('quit()'))
logger = Logger()
logger.show()
app.setMainWidget(logger)
app.exec_loop()
def logwrite():
print(time.ctime())
if __name__ == "__main__":
app = QApplication(sys.argv)
app.connect(app, SIGNAL('lastWindowClosed()'), app,
SLOT('quit()'))
logger = Logger()
QObject.connect(logger.log, SIGNAL("clicked()"), logwrite)
logger.show()
app.setMainWidget(logger)
app.exec_loop()
QObject.disconnect(logger.log, SIGNAL("clicked()"),
logger.log_timestamp)
#!/usr/local/bin/ruby
require 'qt2'
include Qt2
a = QApplication.new([$0] + ARGV)
hello = QPushButton.new('Hello world!')
hello.resize(100, 30)
a.connect( hello, QSIGNAL('clicked()'), a, QSLOT('quit()'))
a.setMainWidget(hello)
hello.show
a.exec
import org.kde.qt.*;
public class HelloWorld {
public static void main(String[] args)
{
QApplication myapp = new QApplication(args);
QPushButton hello = new QPushButton("Hello World", null);
hello.resize(100,30);
myapp.connect(hello, SIGNAL("clicked"),
this, SLOT("quit()"));
myapp.setMainWidget(hello);
hello.show();
myapp.exec();
return;
}
static {
System.loadLibrary("qtjava");
try {
Class c = Class.forName("org.kde.qt.qtjava");
} catch (Exception e) {
System.out.println("Can't load qtjava class");
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有