diff --git a/src/prgag/fibui_place.py b/src/prgag/fibui_place.py new file mode 100644 index 0000000..1cd26a2 --- /dev/null +++ b/src/prgag/fibui_place.py @@ -0,0 +1,55 @@ +#! /usr/bin/env python +# -*- coding: cp1252 -*- +# Copyright (c) 2015 Andreas +# See LICENSE for details. + +""" gui.fibui2 """ + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals +from Tkinter import * +import ttk + + +class Application(Frame): + def createWidgets(self, master=None): + # Set background of toplevel window to match + # current style + style = ttk.Style() + theme = style.theme_use() + default = style.lookup(theme, 'background') + master.configure(background=default) + + self.eingabe = Entry(master) + self.eingabe.place(relx=0.04, rely=0.04, relheight=0.08, relwidth=0.55) + self.eingabe.configure(background="white") + + self.knopf = Button(master) + self.knopf.place(relx=0.7, rely=0.04) + self.knopf.configure(pady="0") + self.knopf.configure(text="Fibo") + self.knopf.configure(command=self.fibo) + + self.ausgabe = Text(master) + self.ausgabe.place(relx=0.04, rely=0.21, relheight=0.7, relwidth=0.85) + self.ausgabe.configure(background="white") + self.ausgabe.configure(height="164") + self.ausgabe.configure(width="194") + self.ausgabe.configure(wrap="none") + + def fibo(self): + nstring = self.eingabe.get() + n= int(nstring) + self.ausgabe.insert(END, "{}\n".format(n)) + + def __init__(self, master=None): + Frame.__init__(self, master) + self.createWidgets(master) + + +root = Tk() +app = Application(master=root) +app.mainloop() +# root.destroy() diff --git a/src/prgag/fibwebui1.py b/src/prgag/fibwebui1.py new file mode 100644 index 0000000..d77c08f --- /dev/null +++ b/src/prgag/fibwebui1.py @@ -0,0 +1,41 @@ +#! /usr/bin/env python +# -*- coding: cp1252 -*- +# Copyright (c) 2015 Andreas +# See LICENSE for details. + +""" prgag.fibusrv """ + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals +import SocketServer + + +class MyTCPHandler(SocketServer.BaseRequestHandler): + """ + The RequestHandler class for our server. + + It is instantiated once per connection to the server, and must + override the handle() method to implement communication to the + client. + """ + + def handle(self): + # self.request is the TCP socket connected to the client + self.data = self.request.recv(1024).strip() + print("---") + print("{} wrote:".format(self.client_address[0])) + print(self.data) + print("---") + # just send back the same data, but upper-cased + self.request.sendall(self.data.upper()) + + +if __name__ == "__main__": + HOST, PORT = "localhost", 8080 + # Create the server, binding to localhost on port 9999 + server = SocketServer.TCPServer((HOST, PORT), MyTCPHandler) + # Activate the server; this will keep running until you + # interrupt the program with Ctrl-C + server.serve_forever() diff --git a/src/prgag/fibwebui2.py b/src/prgag/fibwebui2.py new file mode 100644 index 0000000..553d8ab --- /dev/null +++ b/src/prgag/fibwebui2.py @@ -0,0 +1,61 @@ +#! /usr/bin/env python +# -*- coding: cp1252 -*- +# Copyright (c) 2015 Andreas +# See LICENSE for details. + +""" prgag.fibusrv """ + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals +import SocketServer + +RESPONSE = """ +HTTP/1.1 200 OK +Content-Type: text/html + + +
+ +