Python Forum
Not Getting The desired output on my system
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not Getting The desired output on my system
#1
from tkinter import *
import random

class ExamGuru:
    def _init_(self, parent):
        self.parent=parent
        self.index=0
        self.question_num=1
        self.score=0
        self.questions=[Question("First Insurance Company In India ? ", "Oreintal Life Insurance",["Bombay Mutual Insurance","Western India Insurance","LIC"]),
                        Question("Which Of The Following Risks Are Insurable ?", "Financial Risk",["Non Financial","Both","None"])]

        self.mainquestionframe= Frame(parent, bg="orange", width=800, height=500)
        self.mainquestionframe.pack_propagate(0)
        self.mainquestionframe.pack(pady=5)

        self.headingframe= Frame(self.mainquestionframe, bg="blue",Width=800, height=40)
        self.headingframe.pack_propagate()
        self.headingframe.pack(pady=5)


class Question:
    def _init_(self,question,answer,dummies):
        self.question=question
        self.answer=answer
        self.dummies=dummies
        self.set_answers()

    def set_answers(self):
        self.answers=self.dummies
        self.answer.insert(random.randrange(len(self.dummies)+1), self.answer)


if __name__=='__main__':
    root=Tk()
    
    root.title("Exam Guru")
    root.mainloop()
not getting any anything on the tkinter window
system- ubuntu 14.04
python version - 3.4.3
Reply
#2
You haven't instantiated any classes, so the only code that's going to execute is the code in your if __name__ ... clause
This probably means the window will be incredably small, and your probably just not seeing it.
try adding this line after your title command:
root.geometry('200x200+10+10')
That will give you more surface area to look at.
Reply
#3
(Apr-01-2017, 03:27 PM)Larz60+ Wrote: You haven't instantiated any classes, so the only code that's going to execute is the code in your if __name__ ... clause
This probably means the window will be incredably small, and your probably just not seeing it.
try adding this line after your title command:
root.geometry('200x200+10+10')
That will give you more surface area to look at.

nope its not working either yes the tkinter window is small but its not so small that it cannot be seen nothing is in there expect for the title of the window
Reply
#4
I don't know Tkinter at all but you don't use ExamGuru anywhere.

if __name__=='__main__':
    root=Tk()     
    root.title("Exam Guru")
    app = ExamGuru(master=root)
    app.mainloop()
Ref.: https://docs.python.org/3.5/library/tkin...ld-program
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#5
The instructions I gave you are valid.
Lat me have a look'

try:
from tkinter import *
import random
 
class ExamGuru:
    def _init_(self, parent, title='None', geometry='100x100+10+10'):
        self.parent=parent
        self.parent.geometry(geometry)
        self.title(title)
        self.index=0
        self.question_num=1
        self.score=0
        self.questions=[Question("First Insurance Company In India ? ", "Oreintal Life Insurance",["Bombay Mutual Insurance","Western India Insurance","LIC"]),
                        Question("Which Of The Following Risks Are Insurable ?", "Financial Risk",["Non Financial","Both","None"])]
 
        self.mainquestionframe= Frame(parent, bg="orange", width=800, height=500)
        self.mainquestionframe.pack_propagate(0)
        self.mainquestionframe.pack(pady=5)
 
        self.headingframe= Frame(self.mainquestionframe, bg="blue",Width=800, height=40)
        self.headingframe.pack_propagate()
        self.headingframe.pack(pady=5)
 
 
class Question:
    def _init_(self,question,answer,dummies):
        self.question=question
        self.answer=answer
        self.dummies=dummies
        self.set_answers()
 
    def set_answers(self):
        self.answers=self.dummies
        self.answer.insert(random.randrange(len(self.dummies)+1), self.answer)
 
 
if __name__=='__main__':
    root=Tk()
    ExamGuru(parent=root, title="Exam Guru", geometry='600x400+10+10')
    root.mainloop()
Reply
#6
(Apr-03-2017, 06:35 PM)Larz60+ Wrote: The instructions I gave you are valid.
Lat me have a look'

try:
from tkinter import *
import random
 
class ExamGuru:
    def _init_(self, parent, title='None', geometry='100x100+10+10'):
        self.parent=parent
        self.parent.geometry(geometry)
        self.title(title)
        self.index=0
        self.question_num=1
        self.score=0
        self.questions=[Question("First Insurance Company In India ? ", "Oreintal Life Insurance",["Bombay Mutual Insurance","Western India Insurance","LIC"]),
                        Question("Which Of The Following Risks Are Insurable ?", "Financial Risk",["Non Financial","Both","None"])]
 
        self.mainquestionframe= Frame(parent, bg="orange", width=800, height=500)
        self.mainquestionframe.pack_propagate(0)
        self.mainquestionframe.pack(pady=5)
 
        self.headingframe= Frame(self.mainquestionframe, bg="blue",Width=800, height=40)
        self.headingframe.pack_propagate()
        self.headingframe.pack(pady=5)
 
 
class Question:
    def _init_(self,question,answer,dummies):
        self.question=question
        self.answer=answer
        self.dummies=dummies
        self.set_answers()
 
    def set_answers(self):
        self.answers=self.dummies
        self.answer.insert(random.randrange(len(self.dummies)+1), self.answer)
 
 
if __name__=='__main__':
    root=Tk()
    ExamGuru(parent=root, title="Exam Guru", geometry='600x400+10+10')
    root.mainloop()
i tried ur code executed it but still nothing its same as before

i am on ubuntu 14.04 maybe thats the reason ?
Reply
#7
Please post all traceback code.
If you are not getting an error, it wouldn't hurt to add some print statements here and there to see where faililg
Reply
#8
(Apr-08-2017, 09:29 PM)Larz60+ Wrote: Please post all traceback code.
If you are not getting an error,  it wouldn't hurt to add some print statements here and there to see where faililg

nevermind i ditched that code and starting working with a new one it was getting complex every minute for me
Reply
#9
Quote:it was getting complex every minute for me
Code has a way of doing that. Keep your methods and functions simple,
so only one thing in each
Reply
#10
(Apr-12-2017, 12:01 PM)Larz60+ Wrote:
Quote:it was getting complex every minute for me
Code has a way of doing that. Keep your methods and functions simple,
so only one thing in each
well i tried to keep it as much simple as i can but now i m stuck while making a function to make it run properly can u help me out ?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Json filter is not capturing desired key/element mrapple2020 1 1,073 Nov-24-2022, 09:22 AM
Last Post: ibreeden
  how can I display only desired items? 3lnyn0 5 1,973 Dec-25-2021, 06:49 PM
Last Post: menator01
  ERROR: importing desired module mbgamer28 0 1,648 Apr-05-2021, 07:46 PM
Last Post: mbgamer28
  Not rounding to desired decimal places? pprod 2 2,505 Mar-05-2021, 11:11 AM
Last Post: pprod
  Difference between os.system("clear") and os.system("cls") chmsrohit 7 16,492 Jan-11-2021, 06:30 PM
Last Post: ykumar34
  Why this code not getting desired output ? MDRI 2 2,485 Sep-18-2020, 02:11 AM
Last Post: MDRI
  showing only desired part of a plot grknkilicaslan 1 2,291 Jul-10-2020, 03:51 PM
Last Post: Marbelous
  [Beginner] Code is not producing desired result fakej171 2 2,380 Mar-21-2020, 10:26 AM
Last Post: buran
  Not Getting the Desired value using json.dumps saurabh210 0 1,470 Feb-03-2020, 06:48 PM
Last Post: saurabh210
Question Difference between Python's os.system and Perl's system command Agile741 13 6,653 Dec-02-2019, 04:41 PM
Last Post: Agile741

Forum Jump:

User Panel Messages

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