当前位置: 首页>>代码示例>>Python>>正文


Python Tk.filename方法代码示例

本文整理汇总了Python中tkinter.Tk.filename方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.filename方法的具体用法?Python Tk.filename怎么用?Python Tk.filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tkinter.Tk的用法示例。


在下文中一共展示了Tk.filename方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import filename [as 别名]
def load():
     root = Tk()
     root.withdraw()
     root.filename =  filedialog.askopenfilename(title = "choose your file",
                  filetypes = [("JSON files", ".json"),("All files", "*")])
     pbackup = None
     sbackup = None
     with open(root.filename, 'r') as myfile:
          data=myfile.read()
     try:
          d = jsonLoad(data)
          pbackup = Point.points[1:]
          sbackup = Stick.sticks[:]
          del Point.points[1:]
          del Stick.sticks[:]
          for p in d['points']:
               a = Point(Vector2(p['pos']['x'], p['pos']['y']), p['size'], p['pinned'])
               if p['isMotor']:
                    a.motorize(Vector2(p['spinPos']['x'], p['spinPos']['y']), p['spinSpeed'], p['currentSpin'])
                    a.currentSpin = p['currentSpin']
          for s in d['lines']:
               b = Stick(Point.points[s['p1']], Point.points[s['p2']], s['visible'])
     except Exception:
          messagebox.showinfo("Error", "Invalid JSON")
          if pbackup and sbackup:
               Point.points += pbackup
               Stick.sticks += sbackup
开发者ID:ChickenHoshi,项目名称:verlet-physics-simulator,代码行数:29,代码来源:ragdoll+physics_input.py

示例2: import10ch

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import filename [as 别名]
def import10ch(filename=[],nCh = 10):
    """ Imports *.nch (e.g., .10ch) file and parses it into matlab-structure-like arrays: data['t'][:], etc.
    """
    from tkinter import filedialog
    from tkinter import Tk
    
    if not filename:        
        root = Tk()
        root.filename =  filedialog.askopenfilename(initialdir = "/",title = "Select file",filetypes = (("10ch","*.10chFlt"),("all files","*.*")))
        print (root.filename)
        filename = root.filename
        root.destroy()    
    
    f = open(filename, 'rb')
    A =  np.fromfile(f, np.float32)
    N  = nCh*np.floor(len(A)/nCh).astype(int)# In case the file is incompletely recorded    
    A = A[:N].reshape((-1,nCh)).T
 
    f.close()
    
    ker = np.exp(-np.r_[-60:61:1] **2/(2*20**2.)) # Gaussian kernel
    ch1 = A[0,:]
    smch1 = np.convolve(ch1,ker/ker.sum(),mode='same')
    pow1 = (ch1 - smch1)**2
    ch2 = A[1,:]
    smch2 = np.convolve(ch2,ker/ker.sum(),mode='same')
    pow2 = (ch2 - smch2)**2    
    data  = {}
    data['t'] = np.linspace(1,np.size(A[0,:]),np.size(A[0,:]))/6000.
    data['ch0'] = ch1
    data['ch1'] = ch2
    data['fltCh0'] = np.convolve(pow1,ker/ker.sum(),mode='same')
    data['fltCh1'] = np.convolve(pow2,ker/ker.sum(),mode='same')    
    data['camTrigger'] = A[2,:]
    data['stim0'] = A[5,:]
    data['stim1'] = A[4,:]
    #data['ch5'] = A[3,:]
    #data['ch6'] = A[3,:]
    #data['2pTrigger'] = A[7,:]
    data['filename'] = filename
    return data
开发者ID:avinashpujala,项目名称:Python-code,代码行数:43,代码来源:ephys.py

示例3: Tk

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import filename [as 别名]
         "TAT" : "Tyr", "TAC" : "Tyr", "TAA" : "Stop", "TAG" : "Stop",
         "CAT" : "His", "CAC" : "His", "CAA" : "Gln", "CAG" : "Gln",
         "AAT" : "Asn", "AAC" : "Asn", "AAA" : "Lys", "AAG" : "Lys",
         "GAT" : "Asp", "GAC" : "Asp", "GAA" : "Glu", "GAG" : "Glu",
         "TGT" : "Cys", "TGC" : "Cys", "TGA" : "Stop", "TGG" : "Trp",
         "CGT" : "Arg", "CGC" : "Arg", "CGA" : "Arg", "CGG" : "Arg",
         "AGT" : "Ser", "AGC" : "Ser", "AGA" : "Arg", "AGG" : "Arg",
         "GGT" : "Gly", "GGC" : "Gly", "GGA" : "Gly", "GGG" : "Gly"}

aacode = {"Ala" : "A", "Arg" : "R", "Asn" : "N", "Asp" : "D", "Cys" : "C",
          "Gln" : "Q", "Glu" : "E", "Gly" : "G", "His" : "H", "Ile" : "I",
          "Leu" : "L", "Lys" : "K", "Met" : "M", "Phe" : "F", "Pro" : "P",
          "Ser" : "S", "Thr" : "T", "Trp" : "W", "Tyr" : "Y", "Val" : "V"}

root = Tk()
root.filename = filedialog.askopenfilename(initialdir="D:/강의 관련/'18년 2학기/생화학1/과제/1",
                                           title="Choose your file", filetypes=(("FASTA files","*.fasta"), ("all files","*.*")))
print(root.filename)
root.withdraw()

file = open(root.filename, 'r')
seq = ""
f = file.read().splitlines()
for i in f:
    try:
        if i[0] == '>':
            print(i); continue
        else:
          seq += i
    except IndexError:
        pass
开发者ID:emscb,项目名称:Baekjoon,代码行数:33,代码来源:TmCal.py


注:本文中的tkinter.Tk.filename方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。