Example #1
0
  def new(self):
    from SimpleDialog import *
    import tkSimpleDialog

    self.selection_clear()

    dialog = SimpleDialog(self.root,text="Select data type",
                          buttons=["int","dbl","logical","char","cancel"])
    status = dialog.go()
    if (status == 0):
      ma_type = INT
    elif (status == 1):
      ma_type = DBL
    elif (status == 2):
      ma_type = LOGICAL
    elif (status == 3):
      ma_type = 1000
    else:
      self.set_text("")
      return
		# end if

    name = tkSimpleDialog.askstring("xrtdb","Enter name")
    if (not name):
      self.set_text("")
      return
		# end if

    self.set_text("Edit %s of type %s" % (name,self.ma_type_name(ma_type)))
    self.delete_tmpfile() 
    self.write_tmpfile("Replace this file with your data of type %s" % 
                        self.ma_type_name(ma_type), 1000)
    self.process_tmpfile(name, ma_type, 1)
Example #2
0
    def new(self):

        self.selection_clear()

        dialog = SimpleDialog(
            self.root,
            text="Select data type",
            buttons=["int", "dbl", "logical", "char", "cancel"])
        status = dialog.go()
        if (status == 0):
            ma_type = INT
        elif (status == 1):
            ma_type = DBL
        elif (status == 2):
            ma_type = LOGICAL
        elif (status == 3):
            ma_type = 1000
        else:
            self.set_text("")
            return
# end if

        name = tkSimpleDialog.askstring("xrtdb", "Enter name")
        if (not name):
            self.set_text("")
            return
# end if

        self.set_text("Edit %s of type %s" %
                      (name, self.ma_type_name(ma_type)))
        self.delete_tmpfile()
        self.write_tmpfile(
            "Replace this file with your data of type %s" %
            self.ma_type_name(ma_type), 1000)
        self.process_tmpfile(name, ma_type, 1)
Example #3
0
    def getullimits(self, z):
#        print '%s, %s'%(type(z), z.keycode)
#        print 'get upper low limits'
        ul = self.http_util('ullimits')
        tt = 'upper&lower limits'
        sdl_text = 'Success to get upper&lower, which one you want to copy to clipboard?'
        sdl_bn = ['upper', 'lower', 'cancel']
        if ul=='' or len(ul.split('\n'))!=2:
            tt = 'upper&lower limits::Fail to get'
            sdl_text= 'Maybe server is NOT online.\nMaybe parse fail.'
        
        dlg_ac = SimpleDialog(self.top,
                              title = tt,
                              text = sdl_text,
                              buttons = sdl_bn,
                              default = 0,
                              )
        choose_index = dlg_ac.go()
#        print ul
#        print choose_index
        if sdl_bn[choose_index] in ['upper', 'lower']:
#            self.top.withdraw()
            self.top.clipboard_clear()
#            temp_str = ul.split('\n')[choose_index]
#            print 'choose text, %s'%temp_str
            self.top.clipboard_append(ul.split('\n')[choose_index])
Example #4
0
def showDia():
    dlg = SimpleDialog(root,
                   text = 'hello SimpleDialog',
                   buttons = ['Yes','No','cancel'],
                   default = 0,
                   )
    # 执行对话框
    print dlg.go()
Example #5
0
 def submit(self):
     if 0 in self.result:
         # 创建一个SimpleDialog
         # buttons:显示的按钮
         # default:默认选中的按钮
         dlg = SimpleDialog(self.root,
                            text='你有未选择的题目!',
                            buttons=['确定'],
                            default=0,
                            )
         # 执行对话框
         dlg.go()
     else:
         self.label.destroy()
         self.itema.destroy()
         self.itemb.destroy()
         self.itemc.destroy()
         self.itemd.destroy()
         self.iteme.destroy()
         self.preBt.destroy()
         self.submitBt.destroy()
         score = sum(self.result)
         if score >180:
             label = Message(self.root,text="心理测试结果 :")
             label.place(x=20,y=40)
             message = Message(self.root, text="意志力强,头脑冷静,有较强的领导欲,事业心强,不达目的不罢休。外表和善,内心自傲,对有利于自己的人际关系比较看重,有时显得性格急噪,咄咄逼人,得理不饶人,不利于自己时顽强抗争,不轻易认输。思维理性,对爱情和婚姻的看法很现实,对金钱的欲望一般。 ")
             message.pack()
         elif score >140:
             label = Message(self.root, text="心理测试结果 :")
             label.place(x=20, y=40)
             message = Message(self.root,
                               text="聪明,性格活泼,人缘好,善于交朋友,心机较深。事业心强,渴望成功。思维较理性,崇尚爱情,但当爱情与婚姻发生冲突时会选择有利于自己的婚姻。金钱欲望强烈。")
             message.pack()
         elif score > 100:
             label = Message(self.root, text="心理测试结果 :")
             label.place(x=20, y=40)
             message = Message(self.root,
                               text="爱幻想,思维较感性,以是否与自己投缘为标准来选择朋友。性格显得较孤傲,有时较急噪,有时优柔寡断。事业心较强,喜欢有创造性的工作,不喜欢按常规办事。性格倔强,言语犀利,不善于妥协。崇尚浪漫的爱情,但想法往往不切合实际。金钱欲望一般")
             message.pack()
         elif score > 70 :
             label = Message(self.root, text="心理测试结果 :")
             label.place(x=20, y=40)
             message = Message(self.root,
                               text="好奇心强,喜欢冒险,人缘较好。事业心一般,对待工作,随遇而安,善于妥协。善于发现有趣的事情,但耐心较差,敢于冒险,但有时较胆小。渴望浪漫的爱情,但对婚姻的要求比较现实。不善理财。")
             message.pack()
         elif score >40:
             label = Message(self.root, text="心理测试结果 :")
             label.place(x=20, y=40)
             message = Message(self.root,
                               text="性情温良,重友谊,性格塌实稳重,但有时也比较狡黠。事业心一般,对本职工作能认真对待,但对自己专业以外事物没有太大兴趣,喜欢有规律的工作和生活,不喜欢冒险,家庭观念强,比较善于理财。")
             message.pack()
         else:
             label = Message(self.root, text="心理测试结果 :")
             label.place(x=20, y=40)
             message = Message(self.root,
                               text="散漫,爱玩,富于幻想。聪明机灵,待人热情,爱交朋友,但对朋友没有严格的选择标准。事业心较差,更善于享受生活,意志力和耐心都较差,我行我素。有较好的异性缘,但对爱情不够坚持认真,容易妥协。没有财产观念。")
             message.pack()
Example #6
0
def showDia():
    dlg = SimpleDialog(
        root,
        text='hello SimpleDialog',
        buttons=['Yes', 'No', 'cancel'],
        default=0,
    )
    # 执行对话框
    print dlg.go()
Example #7
0
    def process_tmpfile(self, name, ma_type, isnew):
        from SimpleDialog import *
        # Edit tmpfile
        # Prompt for saving changes
        # Try to read the results
        # Store in the database
        # If it is a new entry update the listbox

        try:
            self.edit_tmpfile()
        except "Edit failed":
            self.set_text("Edit failed")
            self.selection_clear()
# end try

        dialog = SimpleDialog(self.root,
                              text="Save edits?",
                              buttons=["Yes", "No"])
        status = dialog.go()

        if (status == 0):
            try:
                result = self.read_tmpfile(ma_type)
            except "Invalid type":
                return  # msg set in read_tmpfile
# end try

            try:
                rtdb_put(name, result, ma_type)
                self.set_text("%s edits saved" % name)
            except NWChemError:
                self.set_text("%s save failed!" % name)
# end try
            if (isnew):
                # end if
                # end if
                # end def process_tmpfile
                n = 0
                try:
                    while (name > self.listbox.get(n)):
                        n = n + 1
                # end while
                except:
                    pass
                # end try
                self.listbox.insert(n, name)
                self.listbox.see(n)
        else:
            self.set_text("%s nothing saved" % name)

        self.selection_clear()
Example #8
0
  def process_tmpfile(self, name, ma_type, isnew):
    from SimpleDialog import *
    # Edit tmpfile
    # Prompt for saving changes
    # Try to read the results
    # Store in the database
    # If it is a new entry update the listbox

    try:
      self.edit_tmpfile()
    except "Edit failed":
      self.set_text("Edit failed")
      self.selection_clear()
		# end try

    dialog = SimpleDialog(self.root,text="Save edits?",buttons=["Yes","No"])
    status = dialog.go()    

    if (status == 0):
      try:
        result = self.read_tmpfile(ma_type)
      except "Invalid type":
        return  # msg set in read_tmpfile
			# end try

      try:
        rtdb_put(name,result,ma_type)
        self.set_text("%s edits saved" % name)
      except NWChemError:
        self.set_text("%s save failed!" % name)
			# end try
      if (isnew):
			# end if
		# end if
	# end def process_tmpfile
	n = 0
	try:
	  while (name > self.listbox.get(n)):
	    n = n + 1
		# end while
	except:
	  pass
	# end try
	self.listbox.insert(n,name)
	self.listbox.see(n)
    else:
      self.set_text("%s nothing saved" % name)
      
    self.selection_clear()
Example #9
0
    def help(self):
	d = SimpleDialog.SimpleDialog(self.master, 
				      text=usageText(),
				      buttons=["Done"],
				      default=0,
				      title="Help")
	d.go()
Example #10
0
def load():
    global new_name,difficult,level,user_score,user_level,user_index
    canvas.delete(ALL)
    draw_wall()
    try:
        f = open('rank.txt','r')
    except:
        f = open('rank.txt','a')
        f.close()
        canvas.create_text(300,150,text='empty',font='Courier 25 bold')
    else:
        user_lst = [line.strip() for line in f.readlines()]
        f.close()
        if len(user_lst) == 0:
            canvas.create_text(300,150,text='empty',font='Courier 25 bold')
            canvas.create_text(480,350,text='Press b to back',font='Courier 15 bold')
        else:
            user_lst.sort(key = lambda x:int(x.split()[1]),reverse=True)
            canvas.create_text(300,40,text='Name\tScore\tLevel\tDifficulty',font='Courier 15 bold')            
            lst_y = 80
            for i in user_lst:
                canvas.create_text(300,lst_y,text=i,font='Courier 15 bold')
                lst_y += 30
    f = open('rank.txt','r')
    user_lst = [line.strip() for line in f.readlines()]
    f.close()
    user_lst.sort(key = lambda x:int(x.split()[1]),reverse=True)
    if len(user_lst) == 0:
        canvas.create_text(300,150,text='empty',font='Courier 25 bold')
        canvas.create_text(480,350,text='Press b to back',font='Courier 15 bold')
        canvas.focus_set()
        canvas.bind('<Key>',rank_key_event)
    else:
        name_lst = []
        for item in user_lst:
            name_lst.append(item.split()[0])  
        dlg = SimpleDialog(canvas,text='which one to choose',buttons=name_lst,default=0,)
        user_index = dlg.go()
        new_name = user_lst[user_index].split()[0]
        user_score = int(user_lst[user_index].split()[1])
        user_level = int(user_lst[user_index].split()[2])
        difficult = user_lst[user_index].split()[3]
        draw_score()
        show_words()
Example #11
0
 def help(self):
   from SimpleDialog import *
   dialog = SimpleDialog(self.root,
                         text="Quit \t- immediately exits.\n"
                              "Delete \t- deletes selected entry.\n"
                              "Edit \t- edits selected entry, optional save.\n"
                              "New \t- makes new entry, prompts for type+name.\n"
                              "Help \t- this is all that there is.\n"
                              "\n"
                              "Single click on item to select it.\n"
                              "Double click on item to edit it.\n"
                              "\n"
                              "When editing\n"
                              "\t- enter one value per line.\n"
                              "\t- use true/false for logicals.\n"
                              "\t- use 'e' in floating point exponents.\n"
                              "\t- character strings are terminated at EOL.",
                         buttons=["Done"])
   dialog.go()    
 def HelpInfo(self):
     SimpleDialog(self,
         text='Required fields are:\n'
         'Part Width & Length,\n'
         'Amount to Remove,\n'
         'and Feedrate\n'
         'Fractions can be entered in most fields',
         buttons=['Ok'],
         default=0,
         title='User Info').go()
Example #13
0
def rank_del():
    f = open('rank.txt','r')
    user_lst = [line.strip() for line in f.readlines()]
    f.close()
    user_lst.sort(key = lambda x:int(x.split()[1]),reverse=True)
    name_lst = []
    for item in user_lst:
        name_lst.append(item.split()[0])  
    dlg = SimpleDialog(canvas,text='which one to del',buttons=name_lst,default=0,)
    del_index = dlg.go()
    del user_lst[del_index]
    user_lst.sort(key = lambda x:int(x.split()[1]),reverse=True)
    for i in range(0,len(user_lst)-1):
        user_lst[i] += '\n'
    f = open('rank.txt','w')
    f.writelines(user_lst)
    f.close()
    canvas.delete(ALL)
    rank()
Example #14
0
    def Gameover(self):
        DIF = ["", "easy", "normal", "hard"]
        Message = SimpleDialog(self,
                               text="You get %d Points in %s mode, good job!" %
                               (self.Point, DIF[self.NowDif]),
                               buttons=["Yes"])

        self.IsGameOver = True

        return
Example #15
0
def dbMenuOpenFile():
    fd = FileDialog.LoadFileDialog(root)
    filePath = fd.go()
    if filePath!=None:
        dotIndex = filePath.rfind('.')
        if dotIndex!=-1:
            ext = filePath.rsplit('.',1)
            if ext[1]=='db':
                loadTable(filePath)
            else:
                SimpleDialog.SimpleDialog(root,text='请选择sqlite数据库(*.db)文件,\n选择的文件无效.',buttons=['确定']).go()
Example #16
0
 def help(self):
     from SimpleDialog import *
     dialog = SimpleDialog(
         self.root,
         text="Quit \t- immediately exits.\n"
         "Delete \t- deletes selected entry.\n"
         "Edit \t- edits selected entry, optional save.\n"
         "New \t- makes new entry, prompts for type+name.\n"
         "Help \t- this is all that there is.\n"
         "\n"
         "Single click on item to select it.\n"
         "Double click on item to edit it.\n"
         "\n"
         "When editing\n"
         "\t- enter one value per line.\n"
         "\t- use true/false for logicals.\n"
         "\t- use 'e' in floating point exponents.\n"
         "\t- character strings are terminated at EOL.",
         buttons=["Done"])
     dialog.go()
Example #17
0
 def check_and_activate(self):
     # print self.mac.get()
     # Message(root,text = 'hello Message',width = 60).pack()
     # v = StringVar(root)
     # OptionMenu(root,v,'Python','PHP','CPP','C','Java','JavaScript','VBScript')
     alert_msg = ''
     if not self.qq.get() and not self.act_code.get():
         alert_msg = u'QQ号和激活码不能为空!'
     elif not self.qq.get():
         alert_msg = u'QQ号不能为空!'
     elif not self.act_code.get():
         alert_msg = u'激活码不能为空!',
     if alert_msg:
         dlg = SimpleDialog(self.master,
             text = alert_msg,
             buttons = [u'确定'],
             default = 0,
             )
             # 执行对话框
         dlg.go()
     else:
         if self.act_code_is_ok():
             self.write_encryption()
             self.master.destroy()
             
         else:#激活码无效
             alert_msg2 = u'激活码无效, 请重新输入...'
             dlg2 = SimpleDialog(self.master,
                 text = alert_msg2,
                 buttons = [u'确定'],
                 default = 0,
                 )
                 # 执行对话框
             dlg2.go()
Example #18
0
def confirm(root):
    prefix = 'C:\\Windows\\System32\\drivers\\etc\\'
    fileIn = open(prefix+'hosts')
    fileOut = open(prefix+'hosts.new','w')
    for line in fileIn.readlines():
        if '#my black list' in line :
            break
        fileOut.write(line)   
    fileIn.close()     
    fileOut.close()
    os.remove(prefix+'hosts')
    os.rename(prefix+'hosts.new',prefix+'hosts')    
    
       

    
    dlg = SimpleDialog(root,
                       text = 'the blacklist is now closed',
                       buttons = ['ok,i know'],
                       default = 0,
                       )
    print dlg.go()
Example #19
0
def openBlackList(root):
    prefix = 'C:\\Windows\\System32\\drivers\\etc\\'
    fileIn = open(prefix+'hosts')
    fileOut = open(prefix+'hosts.new','w')
    for line in fileIn.readlines():
        fileOut.write(line)   
    fileIn = open('blackList.txt')
    fileOut.write('#my black list\n')
    for line in fileIn.readlines():
        fileOut.write('127.0.0.1\t\t'+line)        
    fileIn.close()     
    fileOut.close()
    os.remove(prefix+'hosts')
    os.rename(prefix+'hosts.new',prefix+'hosts')    

    
    dlg = SimpleDialog(root,
                       text = 'the blacklist is now open',
                       buttons = ['ok,i know'],
                       default = 0,
                       )
    print dlg.go()
Example #20
0
    def sendCmd(self, cmdStr, doConfirm=False):
        """Send an arbitrary command to the alerts actor
        
        Inputs:
        - cmdStr
        """
        if doConfirm:
            dialog = SimpleDialog.SimpleDialog(self,
                                               text="Really %s?" % (cmdStr, ),
                                               buttons=["Yes", "No"],
                                               default=0,
                                               cancel=1,
                                               title="Test Dialog")
            if dialog.go() > 0:
                return

        cmdVar = opscore.actor.keyvar.CmdVar(
            actor="alerts",
            cmdStr=cmdStr,
            timeLim=CmdTimeLimit,
        )
        self.statusBar.doCmd(cmdVar)
Example #21
0
# -*- coding=utf8 -*-
from Tkinter import *
# 引入SimpleDialog模态对话框
from SimpleDialog import *

root = Tk()
# 创建一个SimpleDialog
# buttons:显示的按钮
# default:默认选中的按钮
dlg = SimpleDialog(
    root,
    text='你有未选择的题目!',
    buttons=['确定'],
    default=0,
)
# 执行对话框
dlg.go()
root.mainloop()
Example #22
0
def aboutMenu():
    dlg = SimpleDialog.SimpleDialog(root,text='    三国霸天传数据编辑工具\nprogrammer:viperasi\nweb-site:http://www.xu81.com',buttons=['确定'])
    dlg.go()