예제 #1
0
파일: make.py 프로젝트: ntls/LibreGreek
def dist(fn, a):
    a["locales"] = a["locales"].replace("_", "-")
    a["loc"] = str(dict([[i, [i[0:2], i[3:5], ""]] for i in a["locales"].split(" ")]))
    distname = a["implname"] + "-" + a["version"] + ".oxt"
    z = zipfile.ZipFile(distname, mode="w", compression=zipfile.ZIP_DEFLATED)
    f = open(fn + ".dat", "r")
    code = pythonpath.lightproof_compile___implname__.c(unicode(f.read(), "UTF-8"), a["lang"])
    a["code"] = code["code"]
    a["data"] = code["rules"]

    for i in [
        "META-INF/manifest.xml",
        "description.xml",
        "Linguistic.xcu",
        "Lightproof.py",
        "pythonpath/lightproof_handler___implname__.py",
        "pythonpath/lightproof_impl___implname__.py",
        "pythonpath/lightproof___implname__.py",
    ]:
        z.writestr(i.replace("__implname__", a["implname"]), Template(open(i, "r").read()).safe_substitute(a))

    for i in a["extras"].split(","):
        z.writestr(
            i.strip().replace("../", "").replace("__implname__", a["implname"]),
            open(fn[: fn.rfind("/") + 1] + i.strip()).read(),
        )

    try:
        d = open(fn + ".dlg", "r").readlines()
        Dialog.c(a["implname"], d, z, a["lang"])
    except:
        z.writestr("pythonpath/lightproof_opts_%s.py" % a["implname"], "")
예제 #2
0
    def On_Ok_Button(self, event):

        sock = None
        rsp = None
        groupName = ""

        checklist = self.check_list_box.GetChecked()
        memNum = len(checklist)
        # 不允许建立空群组
        if 0 == memNum:
            dialog = Dialog.Dialog(None, u"错误", u"群内好友数不能为0", 200, 150, 60, 60)
            dialog.Centre()
            dialog.Show()

        groupName = self.groupName_edit.GetValue()
        memList = []
        memberString = ""
        for i in range(memNum):
            memList.append(Login.FRIEND_ID_ARRAY[i])
        for i in range(memNum):
            memberString += chr(len(memList[i]))
            memberString += memList[i]

        send_data = Constant.ADD_GRO_REQ_SUC_RSP + \
                chr(len(str(Login.USERID))) + \
                str(Login.USERID) + \
                chr(len(groupName.encode('utf-8'))) + \
                str(groupName.encode('utf-8')) + \
                chr(len(str(memNum))) + \
                str(int(memNum)) + \
                memberString

        try:
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            sock.settimeout(10)
            sock.connect((Login.SERVER_IP, int(Login.SERVER_PORT)))
            sock.send(send_data)
            rsp = sock.recv(64)
        except Exception, e:
            dialog = Dialog.Dialog(None, u"错误", e.message, 200, 150, 30, 60)
            dialog.Centre()
            dialog.Show()
            self.isSuccess = False
예제 #3
0
def OpenFile(parent, ignore):
	import Dialog
	path = Dialog.OpenFile(parent, 'Text', 'txt')
	if not path:
		return
	fp = open(path, 'r')
	try:
		return fp.read()
	finally:
		fp.close()
예제 #4
0
def SaveToFile(parent, text):
	import Dialog
	path = Dialog.SaveFile(parent, 'Text', 'txt')
	if not path:
		return
	fp = open(path, 'w')
	try:
		fp.write(text)
	finally:
		fp.close()
예제 #5
0
 def errordialog(self, exc, msg):
     # Display an error dialog -- return when the user clicks OK
     Dialog.Dialog(
         self.root, {
             'text': str(msg),
             'title': exc,
             'bitmap': 'error',
             'default': 0,
             'strings': ('OK', ),
         })
예제 #6
0
 def add(self, widget):
     print "add"
     dialog = Dialog.AddActivityDialog(self.wTree)
     result, activity = dialog.run()
     if (result == 1):
         print "dodanie" + activity.name
         self.user.activities_list.append(activity)
         self.session.add(activity)
         self.session.commit()
         self.refresh()
예제 #7
0
    def parse(self, str):
        fh = open(str, 'r')
        content = fh.readlines()
        lines = []
        for line in content:
            lines.append(line)
        fh.close()
        i = 0
        index = 0
        while (i < len(lines)):
            line = lines[i]

            if line[:4] == '\cf0':
                #print 'entered if'
                i += 2
                line = lines[i]
                timestamp = line[5:]
                timestamp = timestamp[:(len(timestamp) - 7)]

                i += 2
                line = lines[i]
                content = line[5:len(line) - 2]

                i += 4
                line = lines[i]
                date = line[5:(len(line) - 7)]

                i += 2
                line = lines[i]
                time = line[5:(len(line) - 7)]

                i += 2
                line = lines[i]
                speaker = line[5:(len(line) - 7)]
                if speaker not in self.speakerDict:
                    self.speakerDict[speaker] = []
                    self.speakerToClass[speaker] = Person.Person(
                        speaker, self.speakerDict[speaker])

                i += 2
                line = lines[i]
                recipients = line[5:(len(line) - 7)]

                i += 2
                line = lines[i]
                startsAt = line[5:(len(line) - 12)]

                self.dialogues.append(
                    Dialog.Dialog(timestamp, content, date, time, speaker,
                                  recipients, startsAt))
                self.speakerDict[speaker].append(index)
                index += 1
                i += 4
            else:
                i += 1
예제 #8
0
    def add_exec_button_clicked(self, widget):

        path = self.check_user_desktop()

        fcb = Dialog.FileDialog(self.core.lri.main_window,
                                _("Please choose a file"), path)
        response = fcb.run()
        #Creo las listas de ayuda para anyadir paquetes si no existen antes
        self.exec_list_init()

        if response == Gtk.ResponseType.OK:
            exec_url = fcb.get_filename()
            fcb.destroy()
            pkg = os.path.basename(exec_url)
            lines = subprocess.Popen(
                ["LAGUAGE=en_EN; md5sum %s | awk '{print $1}'" % exec_url],
                shell=True,
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE).communicate()[0]
            for line in lines.splitlines():
                md5 = line.decode('utf-8')
            pkg_tupla = [pkg, md5]
            #Compruebo si existe el paquete en la lista
            if any(pkg in element
                   for element in self.core.current_var["sh"]["packages"]):
                #No es nuevo, compruebo si coincide su md5sum y lo apunto a subir de nuevo
                if pkg_tupla not in self.core.current_var["sh"]["packages"]:
                    #he de eliminar la tupla de la lista que contiene mi elemento con mismo pkg pero con nuevo md5sum
                    for i, [pkg_for, md5_for] in enumerate(
                            self.core.current_var["sh"]["packages"]):
                        if pkg == pkg_for:
                            self.core.current_var["sh"]["packages"].pop(i)
                    #self.core.current_var["sh"]["packages"].remove(pkg_tupla)
                    self.core.current_var["sh"]["packages"].append(pkg_tupla)
                    self.new_execs.append([pkg, exec_url])
                    self.list_new_execs.append(pkg)
            else:
                self.core.current_var["sh"]["packages"].append(pkg_tupla)
                self.new_package_button(pkg)
                #print "paquete nuevo en lista, esta subido??"
                #Compruebo que es accesible via apache, sino lo apunto para copiar cuando aplique.
                exist_in_server = self.core.n4d.app_deb_exist(
                    pkg, self.core.current_var["sh"]["url"])
                if not exist_in_server[0]:
                    #print "No existe este exec lo debo de subir"
                    self.new_execs.append([pkg, exec_url])
                    self.list_new_execs.append(pkg)

            # ###### #
            #print self.core.current_var
            #print self.core.var
            return True
        else:
            fcb.destroy()
            return False
예제 #9
0
def makeid():
    if actname.get() and actpw.get() and actpwc.get() and actpw.get(
    ) == actpwc.get():
        try:
            y = open('%s.dat' % actname.get(), 'r')
        except IOError:
            a = open('%s.dat' % actname.get(), 'w')
            c = open('%smoney.dat' % actname.get(), 'w')
            f = open('%spm.dat' % actname.get(), 'w')
            g = open('%spmp.dat' % actname.get(), 'w')
            h = open('%spmt.dat' % actname.get(), 'w')
            i = open('%spw.dat' % actname.get(), 'w')
            b = open('actlist.dat', 'a')
            a.write(actname.get() + '\n')
            i.write(actpw.get())
            b.write(actname.get() + '\n')
            c.write(str(0))
            f.write(str(0))
            a.close()
            b.close()
            c.close()
            f.close()
            g.close()
            h.close()
            i.close()
            actpwc.set('')
            home()
            w3.destroy()
        else:
            Dialog.Dialog(root,
                          title='alert',
                          bitmap='info',
                          text=u'入力されたIDは常に登録されています',
                          strings=['OK'],
                          default=0)
    else:
        Dialog.Dialog(root,
                      title='alert',
                      bitmap='info',
                      text=u'アカウント情報を入力してください',
                      strings=['OK'],
                      default=0)
예제 #10
0
 def get(self):
     value = FloatEntry.get(self)
     ivalue = int(value)
     if ivalue != value:
         Dialog.Dialog(self, title='Illegal value',
                       text='The value of "' + self.name +
                            '" must be an integer.',
                       bitmap='warning', default=0,
                       strings = ('Cancel',))
         raise ValueError
     return ivalue
예제 #11
0
def don():
    a = codecs.open('item1.dat', 'w', 'shift-jis')
    b = codecs.open('item2.dat', 'w', 'shift-jis')
    c = codecs.open('item3.dat', 'w', 'shift-jis')
    d = codecs.open('item4.dat', 'w', 'shift-jis')
    e = codecs.open('item5.dat', 'w', 'shift-jis')
    f = codecs.open('item6.dat', 'w', 'shift-jis')
    g = codecs.open('item7.dat', 'w', 'shift-jis')
    h = codecs.open('item8.dat', 'w', 'shift-jis')
    i = codecs.open('item9.dat', 'w', 'shift-jis')
    j = codecs.open('item10.dat', 'w', 'shift-jis')
    k = open('item1pr.dat', 'w')
    l = open('item2pr.dat', 'w')
    m = open('item3pr.dat', 'w')
    n = open('item4pr.dat', 'w')
    o = open('item5pr.dat', 'w')
    p = open('item6pr.dat', 'w')
    q = open('item7pr.dat', 'w')
    r = open('item8pr.dat', 'w')
    s = open('item9pr.dat', 'w')
    t = open('item10pr.dat', 'w')
    u = open('wallet.dat', 'w')
    a.write('empty')
    b.write('empty')
    c.write('empty')
    d.write('empty')
    e.write('empty')
    f.write('empty')
    g.write('empty')
    h.write('empty')
    i.write('empty')
    j.write('empty')
    u.write('0')
    k.write('0')
    l.write('0')
    m.write('0')
    n.write('0')
    o.write('0')
    p.write('0')
    q.write('0')
    r.write('0')
    s.write('0')
    t.write('0')
    f1 = open('owner.dat', 'w')
    f1.write('abc')
    f2 = open('pw.dat', 'w')
    f2.write('12345')
    Dialog.Dialog(root,
                  title='done',
                  bitmap='info',
                  text='初期化が完了しました。管理者 ID:abc PW:12345',
                  strings=['OK'],
                  default=0)
    sys.exit()
예제 #12
0
    def error_up_dialog(self, pkg_name):

        main_window = self.core.lri.main_window
        dialog = Dialog.ErrorDialog(
            main_window, _("Error in publishing"),
            _("This %s package can't be uploaded to server.\nPlease review the parameters or inform to LliureX Team."
              ) % pkg_name)
        response = dialog.run()
        dialog.destroy()

        return True
예제 #13
0
    def error_extension_dialog(self, pkg_name):

        main_window = self.core.lri.main_window
        dialog = Dialog.ErrorDialog(
            main_window, _("Error in Extension"),
            _("This %s package has not the extension required.\nPlease only DEB packages in this list."
              ) % pkg_name)
        response = dialog.run()
        dialog.destroy()

        return True
예제 #14
0
 def confirm_quit(self):
     d = Dialog(None,
                title="Goodbye?",
                text="Really Leave?",
                default=0,
                bitmap=DIALOG_ICON,
                strings=("Yes", "No"))
     if d.num == 0:
         self.monitor_refresh_thread.stop_loop()
         self.quit()
     return
예제 #15
0
	def delete_package_dialog(self,pkg_name):
		
		main_window=self.core.lri.main_window
		dialog=Dialog.QuestionDialog(main_window,_("Delete package"),_("Do you want to delete '%s'?")%pkg_name)
		response=dialog.run()
		dialog.destroy()
		
		if response== Gtk.ResponseType.OK:
			return True
		
		return False
예제 #16
0
def makeid():
    if actpw.get() and actpwc.get() != "":
        if actpw.get() == actpwc.get():
            try:
                e1 = enckey.encrypt(actpw.get())
            except ValueError:
                pwcon.set(u'パスワードは8文字で入力してください')
            else:
                if actpw.get() and actpwc.get() and actpw.get() == actpwc.get():
                    idf = ids
                    os.mkdir("Users")
                    os.chdir("Users")
                    os.mkdir("Admin")
                    os.chdir("Admin")
                    os.mkdir("ad")
                    os.mkdir("Market")
                    os.mkdir("Memo")
                    a = open('user.dat', 'w')
                    c = open('money.dat', 'w')
                    i = open('pw.dat', 'w')
                    p = open('Path.dat', 'w')
                    x = open('License.dat', 'w')
                    x.write(ugoku)
                    p.write(currentdir)
                    a.write(idf)
                    e1 = enckey.encrypt(actpw.get())
                    i.write(e1)
                    c.write(str(0))
                    a.close()
                    x.close()
                    c.close()
                    i.close()
                    try:
                        shutil.move("user.dat", "ad")
                    except WindowsError:
                        pass
                    try:
                        shutil.move("money.dat", "Market")
                    except WindowsError:
                        pass
                    try:
                        shutil.move("pw.dat", "ad")
                    except WindowsError:
                        pass
                    Dialog.Dialog(root, title = 'done', bitmap = 'info',
                                  text = u'設定を適用するために動してください',
                                  strings = ['OK'], default = 0)
                    sys.exit()
                else:
                    pwcon.set(u'アカウント情報を正しく入力してください')
        else:
            pwcon.set(u'アカウント情報を正しく入力してください')
    else:
        pwcon.set(u'アカウント情報を入力してください')
예제 #17
0
    def error_send_dialog(self, pkg_name):

        main_window = self.core.lri.main_window
        dialog = Dialog.ErrorDialog(
            main_window, _("Sending Package Error"),
            _("This list %s cannot be sended to server\nPlease review your share directory\n\n/var/www/llx-remote"
              ) % pkg_name)
        response = dialog.run()
        dialog.destroy()

        return True
예제 #18
0
    def error_repos_dialog(self, repo):
        comment = (
            "%s repositorie not is accesible, please wait to connect with it or select other one"
            % repo)
        main_window = self.core.lri.main_window
        dialog = Dialog.ErrorDialog(main_window, _("Repositories Testing"),
                                    comment)
        response = dialog.run()
        dialog.destroy()

        return True
예제 #19
0
 def on_lib_setting(evt, i):
     """
     对指定的词库进行设置
     :param evt:
     :param i: 选中词库在LIBRARIES字典中的编号
     :return:
     """
     setting_dlg = Dialog.SettingDialog(LIBRARIES, LIBRARY_ID[i])
     setting_dlg.ShowModal()
     setting_dlg.Destroy()
     pass
예제 #20
0
 def on_record_info(evt, d):
     """
     查看单词卡片的详细信息
     :param evt:
     :param d: 点击的单词卡片的详细信息(元组)
     :return:
     """
     record_info_dlg = Dialog.RecordInfo(d)
     record_info_dlg.ShowModal()
     record_info_dlg.Destroy()
     pass
예제 #21
0
 def on_record_update(evt, d):
     """
     修改单词卡片
     :param evt:
     :param d: 点击的单词卡片的详细信息(元组)
     :return:
     """
     record_update_dlg = Dialog.UpdateRecord(d)
     record_update_dlg.ShowModal()
     record_update_dlg.Destroy()
     pass
예제 #22
0
def confirmAdd(child):
    DBOperations.addOneUser(memberNOField.get(), memberNameField.get(),
                            memberGender.get(), memberPhoneField.get(),
                            memberBirthField.get(), memberAmontField.get())
    termiantWindow(child)
    Dialog(frame,
           title='提示',
           text='用户添加成功',
           bitmap=DIALOG_ICON,
           default=0,
           strings=('取消', '确定'))
예제 #23
0
    def On_Ok_Button(self, event):

        sock = None
        rsp = None
        friendID = self.friendID_edit.GetValue()

        # 对好友ID进行非空判断
        if "" == friendID:
            dialog = Dialog.Dialog(None, u"错误", u"好友ID不能为空", 200, 150, 60, 60)
            dialog.Centre()
            dialog.Show()
        # 校验好友ID是否为整数
        elif not Tools.idChecker(friendID):
            dialog = Dialog.Dialog(None, u"错误", u"好友ID不合法", 200, 150, 60, 60)
            dialog.Centre()
            dialog.Show()
        # 自己不能加自己为好友
        elif Login.USERID == friendID:
            dialog = Dialog.Dialog(None, u"错误", u"不允许添加自己为好友", 200, 150, 40,
                                   60)
            dialog.Centre()
            dialog.Show()
        else:
            send_data = Constant.ADD_FRI_REQ_SUC_RSP + \
                chr(len(str(Login.USERID))) + \
                chr(len(str(friendID))) + \
                str(Login.USERID) + \
                str(friendID)
            try:
                sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                sock.settimeout(10)
                sock.connect((Login.SERVER_IP, int(Login.SERVER_PORT)))
                sock.send(send_data)
                rsp = sock.recv(1024)
            except Exception, e:
                self.isSuccess = False
                dialog = Dialog.Dialog(None, u"错误", e.message, 200, 150, 30,
                                       60)
                dialog.Centre()
                dialog.Show()
            finally:
예제 #24
0
 def delete(self, widget):
     dialog = Dialog.RemoveActivityDialog(self.wTree)
     name, day, start, stop = dialog.run()
     for i in self.user.activities_list:
         list = i.getList(True)
         if (name == list[0] and day == list[1] and start == list[2]
                 and stop == list[3]):
             self.session.delete(i)
             self.session.commit()
             self.session.expire_all()
             self.refresh()
     print "delete"
예제 #25
0
def test(task, intention, slot):
    global glodal_task1
    global glodal_dialog
    if task == 'cmd':
        print('cmd')
        return
    elif task != glodal_task1:
        glodal_task1 = task
        glodal_dialog = Dialog(task)
    state, values = glodal_dialog.DM.which_intention(intention, slot)
    action = glodal_dialog.DM.select_action(state)
    return ({'state': state, 'slots': values, 'action': action})
예제 #26
0
파일: PNJ.py 프로젝트: WexyR/KNIL
def exe(pnj, q, d, k, b, g):
    """Interagit avec un pnj"""

    txt = Event.generate(
        "event_speak_{0}".format(pnj['name']), q, k, b, d,
        g)  # Genere un evenement associé à la discussion avec ce pnj
    # On recupère (ou non) des détails concernant la quêtes
    if txt:
        f = open("./PNJ_txt/{name}/{txt}.txt".format(
            name=pnj["name"],
            txt=txt))  # On selectionne le texte à dire selon la quete associée
    else:  # Sinon on balance un texte automatique
        quest_name, num = Quest.auto_txt(q, pnj["name"])
        if quest_name and num:
            f = open("./PNJ_txt/{name}/{quest_name}_auto_{num}.txt".format(
                name=pnj["name"], quest_name=quest_name, num=num))
        else:
            f = open("./PNJ_txt/{name}/auto.txt".format(name=pnj["name"]))
    t = f.read()
    Dialog.run_dialog(d, t, speaker=pnj["name"])
    f.close()
예제 #27
0
    def changes_detected_dialog(self):

        dialog = Dialog.QuestionDialog(
            self.main_window, _("Changes detected"),
            _("There are unsaved changes. Do you want to discard them?"))
        response = dialog.run()
        dialog.destroy()

        if response == Gtk.ResponseType.OK:
            return True

        return False
	def help(self):
		"""Help for the widget."""

		import Dialog
		d = Dialog.Dialog(None, {'title': 'Viewer help',
		                         'text': 'Button-1: Translate\n'
		                                 'Button-2: Rotate\n'
		                                 'Button-3: Zoom\n'
		                                 'Reset: Resets transformation to identity\n',
		                         'bitmap': 'questhead',
		                         'default': 0,
		                         'strings': ('Done', 'Ok')})
def delete_account(event):
    ask = tkMessageBox.askyesno(u'確認',u'選択したアカウントを削除しますか?')
    if ask:
        a = [int(x) for x in deletelb.curselection()]
        cur.execute("select site from account limit 1 offset %d" % a[0])
        for sites in cur.fetchall():
            cur.execute("delete from account where site = '%s'" % sites)
        con.commit()
        update()
        Dialog.Dialog(root, title = 'error', bitmap = 'info',
                              text = u'削除しました',
                              strings = ['OK'], default = 0)
예제 #30
0
 def click_button(self):
     dialog = QtWidgets.QDialog()
     ui = Dialog.Ui_Dialog()
     ui.setupUi(dialog)
     dialog.show()
     #Dialog.exec_()
     rep = dialog.exec_()
     if rep == QtWidgets.QDialog.Accepted:
         self.label.setText('点击了OK')
     else:
         self.label.setText('点击了cancel')
     dialog.exec_()
예제 #31
0
 def onOkPressed(self):
     self.saveNRXconfig()
     if self.confirmRX():
         # save RestartX configures after confirmRX
         self.saveRXconfig()
         # trigger the "Restart X" Dialog
         self.popup = Dialog.dlgRestart(self)
         self.popup.dialog.set_title(_("Input Language"))
     else:
         if self.saveMode == IlUtil.NS:
             # if the save mode is Normal Save, close panel immediately
             self.parent.closePanel()
예제 #32
0
async def roll_dice(ctx, arg=None):
    if not arg:
        dice = random.randrange(1, 7)
    else:
        parse = Util.try_parse(int, arg)
        if not parse[0] or parse[1] < 2:
            return await ctx.send(PE.wrong_command())
        else:
            dice = random.randrange(1, parse[1] + 1)
    msg = Dialog.get_dialog('rollDice').format(ctx.author.name, dice)
    msg = Util.change_font_css(msg)
    await ctx.send(msg)
예제 #33
0
	def load_file(self,e):
		path = self.load.get()
		f = open(path,'r')
		r = f.read()
		f.close()
		j = json.loads(r)[0]

		self.clear()

		self.dialog = Dialog()
		self.dialog.load(j)
		root = self.dialog.Nodes[1]
		self.tree.insert('','end','node_1', text=root.NPCText)
		for response in root.Responses:
			self.load_response(root, response)
예제 #34
0
 def onOkPressed(self, widget, data=None):
     if ssml.querychange():
         # save config
         ssml.saveconfig()
         if self.saveMode == IlUtil.IS:
             # close window first
             self.window.destroy()
             # trigger the "Restart X" Dialog
             self.popup = Dialog.dlgRestart(self)
             self.popup.dialog.set_title(_("Input Language"))
         else:
             self.parent.setDetailChange(self.uuid, True)
             self.window.destroy()
     else:
         self.window.destroy()
예제 #35
0
 def onOkPressed(self,widget,data=None):
     #always send ImDic when pressing ok
     self.parent.setImInfoDic(self.curImInfoDic)
     if ssml.querychange():
         #save config
         ssml.saveconfig()
         if self.saveMode==IlUtil.IS:
             #close window first
             self.window.destroy()
             #trigger the "Restart X" Dialog
             self.popup=Dialog.dlgRestart(self)
             self.popup.dialog.set_title(_("Input Language"))
         else:
             self.parent.setAdvanceChange(True);
             self.window.destroy()
     else:
         self.window.destroy()
예제 #36
0
파일: Character.py 프로젝트: adambenn/Game2
 def speak(self, string, duration=5,boxCol=(0,0,255), textCol=(255,255,255)):#makes character say a message
     self.speach = Dialog.dialog(self.world.cam,(self.x + 25, self.y - 50),string,duration,boxCol,textCol)
예제 #37
0
class DialogMaker:
	def new_node(self):
		self.cur_node = self.node_maker.make_node(self.dialog.Nodes)
	def new_response(self):
		self.cur_response = self.node_maker.make_response(self.cur_node, self.dialog.Responses)
	def __init__(self,parent):

		self.dialog = Dialog()
		self.node_maker = NodeMaker(self.dialog)
		self.cur_node = self.node_maker.make_node(self.dialog.Nodes)
		self.cur_response = None

		self.parent = parent
		#sets root as containers parent
		self.container = Frame(parent)

		self.tree = ttk.Treeview(self.container)
		tree = self.tree
		self.tree.grid(row=3,column=0, rowspan=5,columnspan=2,
						ipadx=200,ipady=100)
		# Inserted at the root, program chooses id:
		tree.insert('', 'end', 'node_1', text=self.cur_node.NPCText)
		tree.bind("<Double-Button-1>", self.select)

		self.save_button = Button(self.container, text='save')
		self.save_button.grid(row = 0, column = 4)
		self.save_button.bind('<Button-1>', self.save)

		self.new = Button(self.container, text='new child')
		self.new.grid(row = 1, column = 4)
		self.new.bind('<Button-1>', self.new_child)


		#set up node info
		self.npc_text_label = Label(self.container,text="NPC Text")
		self.npc_text_label.grid(row=2,column=4)
		self.npc_text = Text(self.container,width=30,height=3)
		self.npc_text.grid(row=3,column=4)

		#set up response info
		self.response_text_label = Label(self.container,text="Response Text")
		self.response_text_label.grid(row=2,column=4)
		self.response_text = Text(self.container,width=30,height=3)
		self.response_text.grid(row=2,column=5)	

		self.response_script_label = Label(self.container,text="Response Script")
		self.response_script_label.grid(row=3,column=4)
		self.response_script = Text(self.container,width=30,height=3)
		self.response_script.grid(row=3,column=5)	


		self.rcha_l = Label(self.container,text="Charisma needed")
		self.rcha_l.grid(row=4,column=4)
		self.rcha = Entry(self.container)
		self.rcha.insert(END,'1')
		self.rcha.grid(row=4,column=5)	

		self.link_l = Label(self.container,text="link")
		self.link_l.grid(row=5,column=4)
		self.link = Entry(self.container)
		self.link.grid(row=5,column=5)
		self.link.insert(END, '-1')

		self.load = Entry(self.container)
		self.load.insert(END,"C:\\Firelight\\Squashed\\assets\\Dialogs\\default.JSON")
		self.load.grid(row=0,column=0)

		self.load_button = Button(self.container,text="Load this to file")
		self.load_button.grid(row=0,column=1)
		self.load_button.bind("<Button-1>", self.load_file)


		self.write = Entry(self.container)
		self.write.insert(END,"C:\\Firelight\\Squashed\\assets\\Dialogs\\default.JSON")
		self.write.grid(row=1,column=0)

		self.write_button = Button(self.container,text="Write to file")
		self.write_button.grid(row=1,column=1)
		self.write_button.bind("<Button-1>", self.write_to_file)



		self.npc_id_label = Label(self.container,text="NPCID")
		self.npc_id_label.grid(row=2,column=0)
		self.npc_id = Entry(self.container)
		self.npc_id.grid(row=2,column=1)

		self.show_node()
		self.container.pack()
		self.select(None,'1')
	def write_to_file(self,e):
		self.dialog.save(self.write.get())
	def show_response(self):
		self.npc_text_label.grid_remove()
		self.npc_text.grid_remove()

		self.response_text.grid()
		self.response_text_label.grid()
		self.response_script.grid()
		self.response_script_label.grid()
		self.rcha_l.grid()
		self.rcha.grid()
		self.link_l.grid()
		self.link.grid()

	def show_node(self):
		self.response_text.grid_remove()
		self.response_text_label.grid_remove()
		self.response_script.grid_remove()
		self.response_script_label.grid_remove()
		self.rcha_l.grid_remove()
		self.rcha.grid_remove()
		self.link_l.grid_remove()
		self.link.grid_remove()

		self.npc_text_label.grid()
		self.npc_text.grid()
	def getText(self,textNode):
		s = textNode.get(1.0,END)
		s = s[:len(s)-1]
		return s
	def save(self,e=None):
		self.dialog.NPCID = self.npc_id.get()
		self.cur_node.NPCText = self.getText(self.npc_text)
		self.tree.item('node_'+str(self.cur_node.id),text=self.cur_node.NPCText)

		if self.cur_response:
			self.cur_response.Text = self.getText(self.response_text)
			self.tree.item('response_'+str(self.cur_response.id),text=self.cur_response.Text)

			self.cur_response.Script = self.getText(self.response_script)
			self.cur_response.CharNeeded = self.rcha.get()
			self.cur_response.Link = self.link.get()

	def new_child(self, e):
		self.save()
		
		id = self.tree.selection()[0]
		print id
		type,num = id.split('_')
		if(type=="node"): 

			self.new_response()
			self.tree.insert('node_' + str(self.dialog.Nodes[int(num)].id), 'end',  'response_'+str(self.cur_response.id), text=self.cur_response.Text)

		elif type=="response": 
			self.new_node()
			self.cur_response.Next = self.cur_node.id
			self.tree.insert('response_'+str(self.dialog.Responses[int(num)].id), 'end', 'node_' + str(self.cur_node.id), text=self.cur_node.NPCText)

	def select(self,event, node_id=None):
		if(node_id):
			id = node_id
			type,num = 'node',int('1')
		else:
			id = self.tree.selection()[0]
			print id
			type,num = id.split('_')
		if type == "node":
			self.show_node();
			#reset curnode to selected node

			self.cur_node = self.dialog.Nodes[int(num)]
			print self.cur_node
			#populate nodes with text for the new node

			self.npc_text.delete(1.0,END)
			self.npc_text.insert(END, self.cur_node.NPCText)
		elif type == "response":
			self.show_response();
			self.cur_response = self.dialog.Responses[int(num)]

			self.response_text.delete(1.0,END)
			self.response_text.insert(END, self.cur_response.Text)
			self.response_script.delete(1.0,END)
			self.response_script.insert(END, self.cur_response.Script)

			self.rcha.delete(0,END)
			self.rcha.insert(END, self.cur_response.CharNeeded)

			self.link.delete(0,END)
			self.link.insert(END, self.cur_response.Link)
	def clear(self):
		print self.tree.get_children()
		while len(self.tree.get_children()) > 0:
			self.tree.delete(self.tree.get_children())


	def load_file(self,e):
		path = self.load.get()
		f = open(path,'r')
		r = f.read()
		f.close()
		j = json.loads(r)[0]

		self.clear()

		self.dialog = Dialog()
		self.dialog.load(j)
		root = self.dialog.Nodes[1]
		self.tree.insert('','end','node_1', text=root.NPCText)
		for response in root.Responses:
			self.load_response(root, response)
				
	def load_node(self, parent_response, node):
		parentid = 'response_'+str(parent_response.id)
		id = 'node_'+ str(node.id)
		self.tree.insert(parentid, 'end',id, text=node.NPCText)
		self.node_maker.node_id = node.id
		for response in node.Responses:
			self.load_response(node, response)
	def load_response(self, parent_node, response):
		parentid = 'node_'+str(parent_node.id)
		id = 'response_'+str(response.id)
		self.tree.insert(parentid, 'end',id, text=response.Text)
		self.node_maker.response_id = response.id
		if response.Next:
			self.load_node(response, self.dialog.Nodes[response.Next])
예제 #38
0
class DialogMaker:
	def __init__(self,parent):
		self.node_dict = {}
		self.responses = []
		self.dialog = Dialog()
		self.node_maker = NodeMaker(self.dialog)
		self.cur_node = self.node_maker.make_node(self.dialog.Nodes,self.node_dict)
		self.cur_response = Response(self.cur_node)
		self.cur_node.Responses.append(self.cur_response)
				
		self.parent = parent
		#sets root as containers parent
		self.container = Frame(parent)

		#set up node list
		self.add_node_button = Button(self.container, text="Add NPC Nodes")
		self.add_node_button.grid(row=1,column=0)
		self.add_node_button.bind("<Button-1>", self.add_new_node)

		self.nodes_listbox = Listbox(self.container,selectmode=SINGLE)
		self.nodes_listbox.bind("<Double-Button-1>",self.update_cur_node)
		self.nodes_listbox.grid(row=2,column=0)
		self.container.pack()

		self.npc_id_label = Label(self.container,text="NPCID")
		self.npc_id_label.grid(row=3,column=0)
		self.npc_id = Entry(self.container)
		self.npc_id.grid(row=4,column=0)

		self.write = Entry(self.container)
		self.write.insert(END,"C:\\Firelight\\Squashed\\assets\\Dialogs\\default.JSON")
		self.write.grid(row=5,column=0)

		self.write_button = Button(self.container,text="Write to file")
		self.write_button.grid(row=6,column=0)
		self.write_button.bind("<Button-1>", self.write_to_file)


		#set up node info
		self.npc_text_label = Label(self.container,text="NPC Text")
		self.npc_text_label.grid(row=1,column=1)
		self.npc_text = Text(self.container,width=50,height=7)
		self.npc_text.grid(row=2,column=1)

		self.save_button = Button(self.container,text="Save All")
		self.save_button.grid(row=4,column=1)
		self.save_button.bind("<Button-1>", self.save)


		self.response_listbox_button = Button(self.container,text="Add Response")
		self.response_listbox_button.grid(row=1,column=2)
		self.response_listbox_button.bind('<Button-1>', self.add_new_response)

		self.response_listbox = Listbox(self.container,selectmode=SINGLE)
		self.response_listbox.bind("<Double-Button-1>",self.update_cur_response)
		self.response_listbox.grid(row=2,column=2)

		self.response_text_label = Label(self.container,text="Response Text")
		self.response_text_label.grid(row=1, column=3)
		self.response_text = Text(self.container,width=40,height=7)
		self.response_text.grid(row=2,column=3)

		self.response_script_label = Label(self.container,text="Response Script (json)")
		self.response_script_label.grid(row=3,column=3)
		self.resonse_script = Text(self.container,width=40,height=7)
		self.resonse_script.grid(row=4,column=3)

		self.response_char_label = Label(self.container, text="Charisma Needed (1-10)")
		self.response_char_label.grid(row=5,column=3)
		self.response_char = Entry(self.container)
		self.response_char.insert(END,"1")
		self.response_char.grid(row=6,column=3)

		self.response_next_label = Label(self.container, text="Next Node (id)")
		self.response_next_label.grid(row=7,column=3)
		self.response_next = Entry(self.container)
		self.response_next.insert(END,"0")
		self.response_next.grid(row=8,column=3)

		self.update()
	def add_new_node(self,e):
		new = self.node_maker.make_node(self.dialog.Nodes, self.node_dict)
		self.update()
	def add_new_response(self,e):
		new = Response(self.cur_node)
		self.cur_node.Responses.append(new)
		self.update()

	def update_cur_response(self,e):
		key = self.response_listbox.curselection()[0]
		self.cur_response = self.cur_node.Responses[int(key)]
		self.update()

	def update_cur_node(self,e):
		key = self.nodes_listbox.curselection()[0]
		self.cur_node = self.dialog.Nodes[int(key)]
		self.update()
	def save(self,e):
		self.cur_node.NPCText = self.npc_text.get(1.0,END)
		self.cur_response.Text = self.response_text.get(1.0,END)
		self.cur_response.Script = self.resonse_script.get(1.0,END)
		self.cur_response.CharNeeded = int(self.response_char.get())
		self.cur_response.Next = int(self.response_next.get())
		self.dialog.NPCID = self.npc_id.get()

		print self.write.get()
		self.update()
	def write_to_file(self,e):
		self.dialog.save(self.write.get())
	#updates visuals
	def update(self):
		#update the nodes dropdown
		self.nodes_listbox.delete(0,END)
		for node in self.dialog.Nodes:
			self.nodes_listbox.insert(END, node.get_key())

		self.response_listbox.delete(0,END)
		for response in self.cur_node.Responses:
			self.response_listbox.insert(END, response.Text)

		self.npc_text.delete(1.0,END)
		self.npc_text.insert(END, self.cur_node.NPCText)

		#delete the text
		self.response_text.delete(1.0,END)
		self.response_text.insert(END,self.cur_response.Text)
		#delete the script
		self.resonse_script.delete(1.0,END)
		self.resonse_script.insert(END,self.cur_response.Script)

		self.response_char.delete(0)
		self.response_char.insert(END,str(self.cur_response.CharNeeded))
		self.response_next.delete(0)
		self.response_next.insert(END,str(self.cur_response.Next))
		self.container.pack()
예제 #39
0
	def __init__(self,parent):

		self.dialog = Dialog()
		self.node_maker = NodeMaker(self.dialog)
		self.cur_node = self.node_maker.make_node(self.dialog.Nodes)
		self.cur_response = None

		self.parent = parent
		#sets root as containers parent
		self.container = Frame(parent)

		self.tree = ttk.Treeview(self.container)
		tree = self.tree
		self.tree.grid(row=3,column=0, rowspan=5,columnspan=2,
						ipadx=200,ipady=100)
		# Inserted at the root, program chooses id:
		tree.insert('', 'end', 'node_1', text=self.cur_node.NPCText)
		tree.bind("<Double-Button-1>", self.select)

		self.save_button = Button(self.container, text='save')
		self.save_button.grid(row = 0, column = 4)
		self.save_button.bind('<Button-1>', self.save)

		self.new = Button(self.container, text='new child')
		self.new.grid(row = 1, column = 4)
		self.new.bind('<Button-1>', self.new_child)


		#set up node info
		self.npc_text_label = Label(self.container,text="NPC Text")
		self.npc_text_label.grid(row=2,column=4)
		self.npc_text = Text(self.container,width=30,height=3)
		self.npc_text.grid(row=3,column=4)

		#set up response info
		self.response_text_label = Label(self.container,text="Response Text")
		self.response_text_label.grid(row=2,column=4)
		self.response_text = Text(self.container,width=30,height=3)
		self.response_text.grid(row=2,column=5)	

		self.response_script_label = Label(self.container,text="Response Script")
		self.response_script_label.grid(row=3,column=4)
		self.response_script = Text(self.container,width=30,height=3)
		self.response_script.grid(row=3,column=5)	


		self.rcha_l = Label(self.container,text="Charisma needed")
		self.rcha_l.grid(row=4,column=4)
		self.rcha = Entry(self.container)
		self.rcha.insert(END,'1')
		self.rcha.grid(row=4,column=5)	

		self.link_l = Label(self.container,text="link")
		self.link_l.grid(row=5,column=4)
		self.link = Entry(self.container)
		self.link.grid(row=5,column=5)
		self.link.insert(END, '-1')

		self.load = Entry(self.container)
		self.load.insert(END,"C:\\Firelight\\Squashed\\assets\\Dialogs\\default.JSON")
		self.load.grid(row=0,column=0)

		self.load_button = Button(self.container,text="Load this to file")
		self.load_button.grid(row=0,column=1)
		self.load_button.bind("<Button-1>", self.load_file)


		self.write = Entry(self.container)
		self.write.insert(END,"C:\\Firelight\\Squashed\\assets\\Dialogs\\default.JSON")
		self.write.grid(row=1,column=0)

		self.write_button = Button(self.container,text="Write to file")
		self.write_button.grid(row=1,column=1)
		self.write_button.bind("<Button-1>", self.write_to_file)



		self.npc_id_label = Label(self.container,text="NPCID")
		self.npc_id_label.grid(row=2,column=0)
		self.npc_id = Entry(self.container)
		self.npc_id.grid(row=2,column=1)

		self.show_node()
		self.container.pack()
		self.select(None,'1')
예제 #40
0
    username = ""

    for opt, val in opts:
        if opt in ('-h', '--help'):
            usage()
        elif opt == '--email':
            email = val
        elif opt == '--password':
            password = val
        elif opt == '--username':
            username = val
        elif opt == '--teamname':
            teamname = val

    if not username:
        d=Dialog('Turnkey Linux - First boot configuration')
        username = d.get_input(
            "Mattermost Admin User Name",
            "Enter a username for the Mattermost administrator.", "admin")


    if not email:
        if 'd' not in locals():
            d = Dialog('TurnKey Linux - First boot configuration')

        email = d.get_email(
            "Mattermost Administrator's Email",
            "Enter email address for the Mattermost 'admin' user.",
            "*****@*****.**")

    if not teamname:
예제 #41
0
파일: make.py 프로젝트: arnotixe/lp-nor
                manifest:full-path="Linguistic.xcu" />
</manifest:manifest>"""

manifest2 = """<?xml version="1.0" encoding="UTF-8"?>
<manifest:manifest>
        <manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-component;type=Python"
                manifest:full-path="Lightproof.py"/>
        <manifest:file-entry
                manifest:media-type="application/vnd.sun.star.configuration-data"
                manifest:full-path="Linguistic.xcu" />
</manifest:manifest>"""

code = Compile.c(datadir, lang, "pythonpath/", pkg)
f = open("Lightproof.py", "a")
f.write(code)
f.close()

try:
    Dialog.c(pkg, author, lang, "data/", "dialog/", "pythonpath/", dlg)
    f = open("META-INF/manifest.xml", "w")
    f.write(manifest)
    f.close()
except:
    dlg = False

if not dlg:
    # without dialog
    f = open("META-INF/manifest.xml", "w")
    f.write(manifest2)
    f.close()
예제 #42
0
파일: main.py 프로젝트: santhosh-kasa/MiSim
def Simulate():
    global num_of_sim 
    global op  
    global num_of_inp
    global iter_num
    global current_inp
    global inpcell
    global output_flag
    global usr_selection
    global inparraycell
    global formstr
    global arrayvals
    global simcomplete
    global inp
    
    xlcCalculateNow()
    xlcCalculateDocument()
    if not output_flag:
        xlcAlert("Select a output cell. If selected, click reload")
        return
#     
    checkMIArray=False
    win32com.client.gencache.Rebuild()
    xl_window = get_active_object()
    xl_app = win32com.client.Dispatch(xl_window).Application
    xl_app.Calculation=xlCalculationManual
#     xl_app = win32com.client.GetActiveObject("Excel.Application")
#     win32com.client.gencache.EnsureDispatch(xl_app)
    
    num_of_sim = 0
    if ((inpcell is not None) and formstr == str(inpcell.formula) ): 
        checkMIArray=True
#         xlcAlert('inside looop:'+ str(inp).strip('[]'))
        rect = inpcell.rect
#         xlcAlert(inpcell.address)
#         xlcAlert(str(rect.first_row))
#         xlcAlert(str(rect.first_col))
        selection = xl_app.ActiveSheet.Cells(int(rect.first_row)+1,int(rect.first_col)+1)
#         selection.value = 100
#     inpcell.value = 100
#     xlcAlert("click OK")
    
    app1 = QApplication(sys.argv)
    form = Dialog.popup()
    app1.exec_()
    num_of_sim = int(Dialog.retval())
    usr_selection = str(Dialog.retsel())
    writeFG = Dialog.writeflag()
    if num_of_sim > 0:
        current_inp =1
#         xlcAlert(str(num_of_sim))
        start = time.time()
        op=None
        op = zeros((num_of_inp,num_of_sim))        
        xl_app.ScreenUpdating = False
        xl_app.DisplayStatusBar = False
        xl_app.EnableEvents = False
        for j in range(num_of_inp):
            current_inp = j
            if (checkMIArray):
                selection.Value = inp[current_inp]
            for i in range(num_of_sim):
                iter_num = i
                xlcCalculateDocument()
        end = time.time()
        xl_app.ScreenUpdating = True
        xl_app.DisplayStatusBar = True
        xl_app.EnableEvents = True
        current_inp = 0
        simcomplete= True
#         selection.value = inp[current_inp]
#         selection.Formula = inpcell.formula
        if checkMIArray:    
            fstr = '=MiInput(' + inparraycell.address + ')'
            selection.Formula = fstr
#         xlcAlert(str(checkMIArray))
        if not checkMIArray:
            inp = [0]
        UI.draw(op, inp,usr_selection)
        # Store data in a CSV format
        if checkMIArray:
            popupstr = ''
            for idx,inpvalue in enumerate(inp):
                tupleop = None
                tupleop = tuple(op[idx])
                datastr = "data" + str(idx)
                xl_app.ActiveWorkbook.Names.Add(datastr,tupleop,False)
                popupstr = popupstr + "Output variable for Input " + str(inpvalue) + "is: "+str(datastr) + "\n"
            popupstr = popupstr + "You can use all the excel statistical functions on these variables"
            xlcAlert(popupstr) 
        else:
            tupleop = tuple(op)
            xl_app.ActiveWorkbook.Names.Add("data",tupleop,False)
            xlcAlert("Your Output Variable is 'data'" + "\n" + "You can use all the excel statistical functions on this variable")
        if writeFG:
            config = get_config()
            config.read('pyxll.cfg')
            dir_path = config.get('LOG','path')
            xlcAlert("Data stored at "+str(dir_path))
            file_name = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
            if checkMIArray:
#                 xlcAlert(str(len(op[1])))
                for idx,inpvalue in enumerate(inp):
                    file_name1 = file_name +"-input "+str(inpvalue) +'.csv'
                    if os.path.exists(dir_path): 
                        myfile = open(os.path.join(dir_path, file_name1), 'wb')
                        wr = csv.writer(myfile, dialect='excel')
                        wr.writerow(op[idx])
            else:
                if os.path.exists(dir_path):
                    file_name = file_name + '.csv' 
                    myfile = open(os.path.join(dir_path, file_name), 'wb')
                    wr = csv.writer(myfile, dialect='excel')
                    wr.writerows(op)
예제 #43
0
	def __init__(self,parent):
		self.node_dict = {}
		self.responses = []
		self.dialog = Dialog()
		self.node_maker = NodeMaker(self.dialog)
		self.cur_node = self.node_maker.make_node(self.dialog.Nodes,self.node_dict)
		self.cur_response = Response(self.cur_node)
		self.cur_node.Responses.append(self.cur_response)
				
		self.parent = parent
		#sets root as containers parent
		self.container = Frame(parent)

		#set up node list
		self.add_node_button = Button(self.container, text="Add NPC Nodes")
		self.add_node_button.grid(row=1,column=0)
		self.add_node_button.bind("<Button-1>", self.add_new_node)

		self.nodes_listbox = Listbox(self.container,selectmode=SINGLE)
		self.nodes_listbox.bind("<Double-Button-1>",self.update_cur_node)
		self.nodes_listbox.grid(row=2,column=0)
		self.container.pack()

		self.npc_id_label = Label(self.container,text="NPCID")
		self.npc_id_label.grid(row=3,column=0)
		self.npc_id = Entry(self.container)
		self.npc_id.grid(row=4,column=0)

		self.write = Entry(self.container)
		self.write.insert(END,"C:\\Firelight\\Squashed\\assets\\Dialogs\\default.JSON")
		self.write.grid(row=5,column=0)

		self.write_button = Button(self.container,text="Write to file")
		self.write_button.grid(row=6,column=0)
		self.write_button.bind("<Button-1>", self.write_to_file)


		#set up node info
		self.npc_text_label = Label(self.container,text="NPC Text")
		self.npc_text_label.grid(row=1,column=1)
		self.npc_text = Text(self.container,width=50,height=7)
		self.npc_text.grid(row=2,column=1)

		self.save_button = Button(self.container,text="Save All")
		self.save_button.grid(row=4,column=1)
		self.save_button.bind("<Button-1>", self.save)


		self.response_listbox_button = Button(self.container,text="Add Response")
		self.response_listbox_button.grid(row=1,column=2)
		self.response_listbox_button.bind('<Button-1>', self.add_new_response)

		self.response_listbox = Listbox(self.container,selectmode=SINGLE)
		self.response_listbox.bind("<Double-Button-1>",self.update_cur_response)
		self.response_listbox.grid(row=2,column=2)

		self.response_text_label = Label(self.container,text="Response Text")
		self.response_text_label.grid(row=1, column=3)
		self.response_text = Text(self.container,width=40,height=7)
		self.response_text.grid(row=2,column=3)

		self.response_script_label = Label(self.container,text="Response Script (json)")
		self.response_script_label.grid(row=3,column=3)
		self.resonse_script = Text(self.container,width=40,height=7)
		self.resonse_script.grid(row=4,column=3)

		self.response_char_label = Label(self.container, text="Charisma Needed (1-10)")
		self.response_char_label.grid(row=5,column=3)
		self.response_char = Entry(self.container)
		self.response_char.insert(END,"1")
		self.response_char.grid(row=6,column=3)

		self.response_next_label = Label(self.container, text="Next Node (id)")
		self.response_next_label.grid(row=7,column=3)
		self.response_next = Entry(self.container)
		self.response_next.insert(END,"0")
		self.response_next.grid(row=8,column=3)

		self.update()