Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Customised Learning
#1
Found a code in 2008:
The program doesn't run in my system. Some of the lines I have silenced using hash.
Added a #! in the beginning.
Referred to the page: https://docs.python.org/2.0/ref/genindex.html

There must be some specific differences.

I have glade installed.

Here is the code:
# https://www.overclock.net/forum/144-application-programming/342279-tutorial-using-python-glade-create-simple-gui-application.html
# An ancient program. Will help identify the difference between ancient and new.
# name file as tutGUI.py

#! /usr/bin/env python
 

# Code:

"import" sys
# try:  
# import pygtk  
# pygtk.require("2.0")  
# except:  
# pass  
#"try":
try_stmt: "try" ":"
# "import" gtk  
"import" gtk.glade  
"except":  
print_stmt:     "print" ["GTK Not Availible"]
sys.exit(1)

class adder:

result = 0

def __init__( self, number1, number2 ):
self.result = int( number1 ) + int( number2 )

def giveResult( self ):
return str(self.result)

class leeroyjenkins:

wTree = None

def __init__( self ):
self.wTree = gtk.glade.XML( "main.glade" )

dic = { 
"on_buttonQuit_clicked" : self.quit,
"on_buttonAdd_clicked" : self.add,
"on_windowMain_destroy" : self.quit,
}

self.wTree.signal_autoconnect( dic )

gtk.main()

def add(self, widget):
try_stmt:
thistime = adder( self.wTree.get_widget("entryNumber1").get_text(), self.wTree.get_widget("entryNumber2").get_text() )
except ValueError:
self.wTree.get_widget("hboxWarning").show()
self.wTree.get_widget("entryResult").set_text("ERROR")
return 0
self.wTree.get_widget("hboxWarning").hide()
self.wTree.get_widget("entryResult").set_text(thistime.giveResult())

def quit(self, widget):
sys.exit(0)

letsdothis = leeroyjenkins()

Tried from the Index webpage, but without extensive coding examples, I am finding it difficult to have the final output.

Googling was tried extensively. Unlike Oracle's resources with extensive coding examples for each in-built functions, nothing centralised of that level was yet found for python.

A handful were found:
(1) https://www.programiz.com/python-programming/examples
(2) https://www.pythonforbeginners.com/code-...e-examples
(3) https://www.pythonforbeginners.com/code-...urce-code/
Searching ...

Found another, appears potent and FOSS.
https://www.activestate.com
Freedom is impossible to conceive.
Books that help:
Dale Carnegie's How To Win Friends And Influence People and Emilie Post's Etiquette In Society, In Business, In Politics, And At Home
Have a good day :)
Reply


Messages In This Thread
Customised Learning - by bkpsusmitaa - Sep-27-2018, 02:04 PM
RE: Customised Learning - by Larz60+ - Sep-27-2018, 03:35 PM
RE: Customised Learning - by bkpsusmitaa - Sep-28-2018, 02:23 AM
RE: Customised Learning - by Larz60+ - Sep-28-2018, 10:25 AM
RE: Customised Learning - by bkpsusmitaa - Sep-28-2018, 10:44 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020