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


Python Tk.filename方法代码示例

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


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

示例1: str

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import filename [as 别名]
import sys
import string
import base64
from Tkinter import Tk
from tkFileDialog import askopenfilename
from githubpy import github
from bs4 import BeautifulSoup
import urllib2

token = '33aa8aec26d79b1843d50385cdea04093b90570f'  #Github auth token for authorisation
gh = github.GitHub(access_token=token)
username = str(gh.user.get()['login'])

root = Tk()
root.withdraw()
root.filename = askopenfilename()
filename = str(root.filename)
filename_rev = filename[::-1]


str_file =''
for i in range(30):
	if filename_rev[i] == "/":
		break
	else:
		str_file = str_file + filename_rev[i]

file_name = str_file[::-1]
commit_message = raw_input("Enter your commit Message : ")
#repo_name = raw_input("Enter the repo, you want your code to be pushed: ")
开发者ID:Rahul91,项目名称:python,代码行数:32,代码来源:try_tinker.py

示例2: gitall

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import filename [as 别名]
def gitall():
	'''
	print "For using this app, you need to have Github auth token."
	raw_input("Press Enter to get your token")
	webbrowser.open("https://help.github.com/articles/creating-an-access-token-for-command-line-use/#creating-a-token",new=2)
	token = raw_input("Enter/paste your token : ")
	#print "\nNow, that you have your auth token, from next execution simply comment out first 3 lines of code and paste your token in program itself, save and enjoy.\nYou should find the source-code here:/usr/local/lib/python2.7/dist-packages/gitgui/git_gui.py"
	'''
	
	token = '33aa***************************************0570f'  #Github auth token for authorisation

	gh = github.GitHub(access_token=token)
	username = str(gh.user.get()['login'])

	root = Tk()
	root.withdraw()
	root.resizable(width=800, height=400)
	root.filename = askopenfilename()
	filename = str(root.filename)
	filename_rev = filename[::-1]


	str_file =''
	for i in range(30):
		if filename_rev[i] == "/":
			break
		else:
			str_file = str_file + filename_rev[i]

	file_name = str_file[::-1]
	commit_message = raw_input("Enter your commit Message : ")


	with open(filename) as f:
		file_content = f.read()


	flag1 = 1
	j = 0

	list = gh.user.repos.get()

	while (j<=3):

		repo_name = raw_input("Enter the repo, you want your code to be pushed: ")
		for dictionary in list:
			if str(repo_name) != str(dictionary['name']):
				flag1 = 0
				
			else:
				flag1 = 1
				j = 5
				break

		if flag1 == 0:
			print "I think, you have forgotten your repo names, have a look here, and try again."
			for dictionary in list:
				print dictionary['name']
			j += 1

		if j == 3:
			print "Number of trails exceeded, Aborting."
			sys.exit(1)
			break


	link = "https://github.com/" + username + "/" + str(repo_name)
	url = urllib2.urlopen(link) 
	soup = BeautifulSoup(url)

	con = soup.find_all("a",{"class" : "js-directory-link"})
	count = len(con)

	flag2 = 0

	for title in con:
		if str(file_name) == str(title.text):
			flag2 = 1
			print "You are trying to push a file, which is already there on your remote. This feature is not in this module. Please try later and push a file which is not alrady pushed. Aborting."
			break


	if (flag1==1 and flag2==0):
		encoded_file =  base64.b64encode(file_content)
		gh = github.GitHub(access_token=token)
		username = str(gh.user.get()['login'])
		gh.repos(username)(repo_name)('contents')(file_name).put(path=file_content,message=commit_message,content=encoded_file)
		print ("\nFile '%s' with commit message : '%s' pushed into your repo :'%s'" %(file_name, commit_message, repo_name))
		raw_input("\nPress Enter to exit :)")
开发者ID:Rahul91,项目名称:GitGui,代码行数:91,代码来源:git_gui.py


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