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


Python Tk.fileName方法代码示例

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


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

示例1: openFile

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import fileName [as 别名]
def openFile():
    # Create Tk object.
    root = Tk()
    # Hide blank window.
    root.withdraw()
    # Get user name.
    user = getpass.getuser()
    path = 'C:/Users/%s/Downloads/' % user
    ftypes = (("CSV File", "*.csv"), ("All Files", "*.*"))
    # Get file name.
    root.fileName = askopenfilename(filetypes=ftypes, initialdir=path)
    return root.fileName
开发者ID:SahilMak,项目名称:CSV_2_DB,代码行数:14,代码来源:csv_2_db.py

示例2: open_file

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import fileName [as 别名]
def open_file():
  # Create Tk object
  root = Tk()
  # Hide blank window
  root.withdraw()
  # Get user name
  user = getpass.getuser()
  # Define default open path
  path = 'C:/Users/%s' % user
  # Define file types
  ftypes = (("Text Documents", "*.txt"), ("All Files", "*.*"))
  # Get file name
  root.fileName = askopenfilename(filetypes=ftypes, initialdir=path)
  return root.fileName
开发者ID:SahilMak,项目名称:Entropy_Calculator,代码行数:16,代码来源:entropy_calc.py

示例3: main_alghorithm

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import fileName [as 别名]
 def main_alghorithm(self, answer, soup, counter, sequence, names):
     """
     Main Algorithm, search our result
     :param answer: yes if you want save in file, no if you want result on output
     :param soup:  parser element
     :param counter: helper variable with number of line
     :param sequence: our sequence
     :param names: tuple with names for result
     :return: None
     """
     if answer.lower() == "yes":
         root = Tk()
         root.fileName = filedialog.askopenfilename()
         root.destroy()
         file = open(root.fileName, 'a', encoding='utf-8')
     for row in (soup.find_all(attrs={"class": ["row_table1", "row_table2"]})):
         for i in row.find_all("td"):
             if counter == 14:
                 counter = 0
             if counter % 13 == 0 and counter != 0:
                 sequence += " "
                 counter += 1
                 if answer.lower() == "yes":
                     file.write(sequence + "\n")
                 else:
                     print(sequence)
                 sequence = ""
             elif not i.text == "" or (names[counter] == "Å") or sequence == " ":
                 sequence += names[counter] + " " + i.get_text('\n' + names[counter] + " ").strip()
                 counter += 1
                 if answer.lower() == "yes":
                     file.write(sequence + "\n")
                     sequence = ""
                 else:
                     print(sequence)
                 sequence = ""
     if answer.lower == "yes":
         file.write("\n")
         file.close()
开发者ID:D3XXXt3R,项目名称:ProjectHeisenberg,代码行数:41,代码来源:Helper.py

示例4: main

# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import fileName [as 别名]
def main():
    
    num_ts = int(input ('How many steps in the reaction?: '))
    num = num_ts
    num *= 2
    
    num_files = []
    lst = []
    step = 0    
    
    while num > -1:
        x = 'Enter the number of files at step ' 
        step += 1
        x = x + str(step) +': ' 
        files = int(input(x))
        num_files.append(files)
        while files != 0:
            root = Tk()
            root.withdraw()
            ftypes = [('Gaussian Output File',"*.out"),("Gaussian Log File", "*.log")]
            ttl  = "MATERIAL"
            dir1 = 'C:\\'
            root.fileName = askopenfilename(filetypes = ftypes, initialdir = dir1, title = ttl)
            lst.append(root.fileName)
            root.destroy()
            files -= 1
            
        num -= 1
    
    num_length = len(num_files)
    
    length = len(lst)
    
    values = []
    
    for i in range (1,length+1):
        for n in lst[i-1:i]:
            values.append(gibbs(n))
    
    new_values = []
    fc = 0   
    dc = 0
    for i in range (1,num_length+1):
        for n in num_files[i-1:i]:
            fc += int(n)
            dc += int(-n)
            dc = fc + dc
            add_to = values[dc:fc]
            adder = 0
            for c in add_to:
                adder += round(float(c),4) # remove noise from gaussian calculation.
            dc = 0
            new_values.append(adder)
            
    # Calculate free energy change at each step.
    
    # zero-point is always the first item in the list.
    
    zero = new_values[0:1]
    
    zero_value = 0
    
    for x in zero:
        zero_value += float(x)
    
    plot_x = []
    plot_y = []
    plot_x.append(0)
    plot_y.append(0)
    
    for i in range (1,num_length):
        for n in new_values[i:i+1]:
             numba = n - zero_value
             numba = numba*627.503 # convert to a.u.
             numba = round(numba,1) # round to 1 decimal place. 
             plot_x.append(numba)
             plot_y.append(0)
    
    
    # formatting chart.
          
    final_y = []
    
    for i in plot_x:
        final_y.append(i)
        final_y.append(i)
    
    final_x = []
    
    for i in range(1,len(final_y)+1):
        final_x.append(i)
    
     
    final_z = []
    
    for i in plot_y:
        final_z.append(i)
        final_z.append(i)
        
    # use our graph function to graph the results!
#.........这里部分代码省略.........
开发者ID:tewest,项目名称:GaussPlot,代码行数:103,代码来源:Gauss_plot.py


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