I've seen the following code for binding the Escape Key to a Tkinter GUI: import Tkinter as tk def exit(): root.destroy() root = tk.Tk() root.bind("<Escape>", exit) root.mainloop() However, when I add this to my GUI program, I don't get a response when Esc key is pressed. It does nothing. Any suggestions?

Member Avatar
+0 forum 0

Hi! My name is Steven and I am a computer science student. I've been working on a project recently (just for fun, practice, and because I was bored lol). I need some testers. It is a game engine for developing text based games in python (3). As of now, it is in very early stages. I need some people to try to develop with it, find bugs, or just suggest features. It is available to download from github [here](https://github.com/tman540/T.A.R.B.S.-Engine). There is also documentation for the most recent version [here](https://tautonico-enterprises.gitbook.io/tarbs/). Thanks! Note: I haven't been programming python for too long, so …

Member Avatar
+0 forum 0

![Untitled_spreadsheet_Google_Sheets.png](/attachments/small/2/57c66e06439c72d5acbb2b9623cf737a.png "align-left") I have column A and Column B. I need to create new column C by iterating through Column A and B and if value in Column A is same then merge value in Column B.

Member Avatar
+0 forum 0

I am trying to take a user input from an entry input and display it back to the user in a simpl text widget. I have implementing a label but apparently that's a bad idea for what I desire. Ultimatley, I'd like my gui to look like this: User: Hey Bot: Oh hey there, User: How are you My gui and response code is as follows: #Creating the GUI myText = tk.StringVar() window.resizable(False, False) window.title("Ashley-UDOL Chatbot") window.geometry('400x400') User_Input = tk.Entry(window, textvariable=myText, width=50).place(x=20, y=350) subButton = tk.Button(window, text="Send", command=Response).place(x =350, y=350) displayText = Text(window, height=20, width=40).pack() scroll = Scrollbar(window, command=displayText).pack(side=RIGHT) window.mainloop() …

Member Avatar
+0 forum 0

I am facing issue while appending fieldlist through append_entry in flask-wtf. I am able to add one row of fields from fieldlist but after adding first row, i am not able to add second row. No errors are shown. In first attempt a new row is added of field list items and in server log "Data is King" and "True" is printed {I have included this to see if add button sends data and loop actually goes through}. In second attemt new row is not added but page reloads and in server log "Data is King" and "True" is printed …

Member Avatar
+0 forum 0

Hi everyone I have this code that I am using from a book, it seems that it does not run correctly, I am new to tkinter and trying to understand how its lay out is supposed to work, is this code up-to-date with using pycharm? I have tried pycharm and IDLE, but it does not display all the widgets as talked about in the book, is there other modules/functions that should be arranged into this or have I done too many typos? from tkinter import * class Application(Frame): def __init__(selfself, master): super(Application, self).__init__(master) self.grid() self.create_widgets() def create_widgets(self): Label(self, text="enter information …

Member Avatar
+0 forum 0

Hello. I found this packet sniffer code that uses the pycap wrapper. Initially, its for live capture but I've changed it to read a .pcap file instead and im trying to understand it but some parts of it i can't i comprehend. could someone explain them to me please? the full code is: import socket from struct import pack, unpack import pcapy import sys def main(argv): dev = input("Enter file name to sniff : ") print("Sniffing file " + dev) # Read offline cap = pcapy.open_offline(dev) #start sniffing packets while(1) : (header, packet) = cap.next() parse_packet(packet) # change to string …

Member Avatar
+0 forum 0

Im trying to find for bytes(unknown) that appear before another set of bytes that have already been found. i have a binary file that for example looks like this: 82 00 10 00 00 00 00 00 00 00 00 00 00 01 00 00 60 F8 6C 10 BF 58 87 45 87 6F 0C 61 0D 26 B0 F5 10 00 00 00 01 00 11 00 00 00 00 00 0E 00 11 00 2D 00 04 00 72 46 13 F4 18 43 C0 D2 0A 64 24 91 F3 E7 00 80 54 00 4E …

Member Avatar
+0 forum 0

when we telnet a multi layer switch for its trace route to a specific host, I need to get router name instead of point-to-point name or IP. I would need to Write a script/program which takes the switch/router name and destination host as input. The script need to return list of router name in between. any advice where to start? I have zero knowledge on scripting..

Member Avatar
+0 forum 0

# An orders class def __init__(self, order): # Initialise self.ID = order.order_id self.kits = [] kit = {} for x in order.kits: # Add kit kit['Type'] = x.kit_type kit['Objects'] = x.objects self.kits.append(kit)

Member Avatar
+0 forum 0

INSERT [table].[Region] ([RegionID], [RegionDesc]) VALUES (1, N'East') INSERT [table].[Region] ([RegionID], [RegionDesc]) VALUES (2, N'West') INSERT [table].[Region] ([RegionID], [RegionDesc]) VALUES (3, N'North') INSERT [table].[Region] ([RegionID], [RegionDesc]) VALUES (4, N'South') I have a text file like above. From the above insert statements i want to write code so that it turns into a python list thing like. Output should be [table].[Region]:- [RegionID] [RegionDesc] 1 N'East 2 N'West 3 N'North how to achieve this kind of result. plz help

Member Avatar
+0 forum 0

Hi, how would you output the values of a foreign key. For example: if there is a table with two foreign keys (which are linked to other tables), how would you output the values of those foreign keys.

Member Avatar
+0 forum 0

In [this page](https://uwsgi.readthedocs.io/en/latest/WSGIquickstart.html), the first example of using python with uwsgi is the following code: def application(env, start_response): start_response('200 OK', [('Content-Type','text/html')]) return [b"Hello World"] As you can see, there is this `start_response` function which is provided by uwsgi, which is similar to all those things that framewroks like django provide to receive and reply requests. So...does uwsgi provide enough of these things so that you can make a web app with python without using any web framework?

Member Avatar
+0 forum 0

I am trying to delete files in flask after they are downloaded, but I'm hung up on file path issues, generating empty excel files. The file that is downloaded is passed to the route for the file download from a session variable. The following code finds the file and downloads it: @app.route('/dnld_outputfile/', methods=['POST','GET']) def download_output(): output_file1 = session.get('session_variable', None) return send_file(output_file1, attachment_filename='outputfile.xlsx', as_attachment=True) But this code uses a generator to serve and then delete the file: @app.route('/dnld_outputfile/', methods=['POST','GET']) def download_output(): output_file1 = session.get('output_file', None) path = os.path.join(current_app.instance_path,output_file1) def generate(): with open(path) as f: yield from f os.remove(output_file1) r = app.response_class(generate(), …

Member Avatar
+0 forum 0

import turtle import os import math import random import pygame #set up the screen wn = turtle.Screen() wn.bgcolor("black") wn.title("Space invaders") wn.bgpic("space_invaders_backgrounds.gif") pygame.init() #Register the shapes turtle.register_shape("ship.gif") turtle.register_shape("Enemy.gif") #Drawing my border border_pen = turtle.Turtle() border_pen.speed(0) border_pen.color("white") border_pen.penup() border_pen.setposition(-300,-300) border_pen.pendown() border_pen.pensize(3) for side in range(4): border_pen.fd(600) border_pen.lt(90) border_pen.hideturtle() #Set the score to 0 score = 0 #Draw the score score_pen = turtle.Turtle() score_pen.speed(0) score_pen.color("white") score_pen.penup() score_pen.setposition(-290, 280) scorestring = "Score: %s" %score score_pen.write(scorestring, False, align="left", font=("Arial", 14, "normal")) score_pen.hideturtle() #create the player turtle player = turtle.Turtle() player.color("blue") player.shape("ship.gif") player.penup() player.speed(0) player.setposition(0, -250) player.setheading(90) playerspeed = 18 #Choose a number of enemies number_of_enemies …

Member Avatar
+0 forum 0

from PyQt5 import QtCore, QtGui, QtWidgets # Import the PyQt5 module we'll need import sys # We need sys so that we can pass argv to QApplication import design # This file holds our MainWindow and all design related things # it also keeps events etc that we defined in Qt Designer import os # For listing directory methods class ExampleApp(QtWidgets.QMainWindow, design.Ui_MainWindow): def __init__(self): # Explaining super is out of the scope of this article # So please google it if you're not familar with it # Simple reason why we use it here is that it allows us to …

Member Avatar
+0 forum 0

Hi guys, I developed JIT compiler for Python. It compiles simplified Python code directly to x86 native code. Focus here is usage on SIMD instructions. With SIMDy you can easily outperform C++ in compute intensive tasks like monte carlo simulations, rendering, fluid simulations, etc... Web(WIP): www.tahir007.com I would like to hear your opinions about SIMDy package!

Member Avatar
+0 forum 0

I have two dataframes and I need to separate rows where a value from pmdf matches one of the codes in jcrdf.All_codes. If pmdf.code is in jcrdf.All_codes, I need a dataframe with all values from jcrdf AND pmdf.count. Dataframes: pmdf = pd.DataFrame( { 'code': ['0567-8315','0007-4977','0096-0225','1365-2133','8675-309J'], 'count':['6','7','10','2','1'] } ) jcrdf = pd.DataFrame( { 'jobtitle': ['manager','technician','noob','retiree'], 'location': ['loc1','loc3','loc4','loc2'], 'jcode' : ['4444-4444','3333-3333','2222-2222','1111-1111'], 'All_codes': ['0096-0225,0096-0225','1820-7448,0567-8315,0567-8315','0007-4977,0007-4977','0007-0963,0007-0963,0366-077X,1365-2133'] }) I have a lookup that allows for a diff: jcrdf_lookup = pd.DataFrame(jcrdf['All_codes'].str.split(',').tolist(), index=jcrdf.jcode).stack(level=0).reset_index(level=0) matches = jcrdf_lookup[jcrdf_lookup[0].isin(pmdf.code)] jcrdfmatch = jcrdf[jcrdf.jcode.isin(matches.jcode)] jcrdfnomatch = pmdf[~pmdf.code.isin(matches[0])] But I can't figure out how to include pmdf.count. I tried making a df of the …

Member Avatar
+0 forum 0

hello freinds i have put an image (self.image) on my window background now, i need to put another image(mi_but1) on this window.. my problem: image mi_but1 is put on window with a gray square behind it(a gray square between image mi_but1 and window's background) .the final gui doesnt look nice.i don't want this gray background... what should I do? how can i remove this gray square behind the button(button background)? OR how can i put the image of window background(self.image) in behind of the button (button background) my code: from tkinter import * from PIL import Image, ImageTk root = …

Member Avatar
+0 forum 0

I want to display the content of selected treeview only in tkinter but when i select the treeview other treeview content also display but i want only the selected treeview to display. I have working around to get this by the use of style widget but it display other content to which i dont want to display until i select it to display. from tkinter import * from tkinter import ttk import tkinter as tk root =Tk() root.geometry("1000x450") tree = ttk.Treeview(root) tree.insert("","0","item1",text="LANGUAGE") tree.insert("","1","item2",text="GUI") tree.insert("item1", "0", text="pyhton") style = ttk.Style(root) style.configure("Treeview", rowheight=50) tree.configure(style="Treeview") tree.config(columns=("NOTE","book")) tree.column("NOTE",width=300) tree.heading("NOTE",text="Info") tree.column("book",width=300) tree.heading("book",text="profile") tree.set("item1","NOTE","Am using python …

Member Avatar
+0 forum 0

Hello everybody! Today i am writing a program to connect usées without database, with only one function: `createaccount(username,password)` That you must write on the beginning if the program. But i don't know how to finish it, with the "connect" function : class User(): def init(self, inputusername="a", inputpassword="b"): self.username = str(inputusername) self.password = str(inputpassword) def createaccount(user,pw): user = User(user,pw) def connect(userinput,pwinput): what? def loadaccounts(): createaccount("user1","mypw") createaccount("testuser","testpassword") def askuser(): while True: user = droid.dialogGetInput("User","Entrez votre nom d'utilisateur").result pw = droid.dialogGetPassword("Password","Entrez votre mot de passe").result if connect(user,pw) == True: print("ok") break else: break I am french, and so my program is. Don't Give …

Member Avatar
+0 forum 0

import urlparse import urllib import urllib2 from bs4 import BeautifulSoup from collections import Counter import re import Tkinter from Tkinter import * import ttk from tkFileDialog import askopenfilename import logging import tkMessageBox import tkFileDialog import csv import json import os import time import collections import shutil import thread from PIL import Image, ImageTk from timeit import default_timer as timer from functools import partial # In[27]: # Identify all the possible links from the starting URL # dedupe the URL list to get the unique list of URLs to scrape url="http://www.dawsons.co.uk/finance-information/" urls=[url] #stack of urls to scrape visited=[url] #historic record of …

Member Avatar
+0 forum 0

How can i set a frame according to parent window size? I was trying to set it but it is taking only region where button displayed from Tkinter import * class Example: def __init__(self, parent): self.parent = parent self.parent.title("CBLFinder") self.initUI() def initUI(self): self.frm1=Frame(self.parent,background="white",\ borderwidth=5,relief="sunken",\ width=400,\ height=500) #print self.parent.winfo_reqwidth(),self.parent.winfo_reqheight() btn=Button(self.frm1,text="Submit",command=self.update_frame) btn.grid(row=2,column=2,padx = 5, pady = 5) self.frm1.grid(row=0,column=0,sticky=(N,S,E,W)) def update_frame(self): self.frm1.grid_forget() def main(): root = Tk() root.geometry("250x150+300+300") app = Example(root) root.mainloop() if __name__ == '__main__': main()

Member Avatar
+0 forum 0

Hey I'm coding Tron which is basically a two player snake game, I'm a noob when it come to pygame and python and need help with the collision logic and would love it if you could help me. (the comments are just ideas I had for the loops for the collisions that didn't work out) I need one loop for when one head touches the other's body which should say which crashed into who and also one loop that kills the snake that runs into himself. import pygame import time import random import os pygame.init() fps = pygame.time.Clock() magenta = …

Member Avatar
+0 forum 0

Hi, i have been making a maze game in pygame. I have made every level and have them all in different folders so i can find them easily. I have been trying to make a menu for the game where you are able to pick any level and play it. i have tried and failed many time in trying this where when you click to play level 1 it open up the folder and that level. if anyone can help it would be amazing import os import pygame import random pygame.init() #Colours im using in the game white = (255,255,255) …

Member Avatar
+0 forum 0

I have a simple pygame code that doesn't seem to be functioning correctly, check it out: import pygame, time active = True screen_size = (1052, 700) pygame.init() DISPLAY = pygame.display.set_mode(screen_size) firstimg = pygame.image.load('firstimage.png') secondimg = pygame.image.load('secondimage.png') clock = pygame.time.Clock() def WHITESCREEN: DISPLAY.fill(255, 255, 255) def DisplayFirstImg(): DISPLAY.blit(firstimg, (1, 1)) def DisplaySecondImg(): DISPLAY.blit(secondimg, (1, 1)) WHITESCREEN() DisplayFirstImg() time.sleep(3) DisplaySecondImg() while active: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() pygame.display.update() clock.tick(15) So this should display 'firstimage.png', wait three seconds, and then display 'secondimage.png'. However it skips the first two steps, going straight to the delay and then displays the second …

Member Avatar
+0 forum 0

I'm using selenium with firefox to load a webpage. The page uses ajax to load new content on clicking the Display More Results button. However when I try to find this button and simulate a click, it gives the following Stacktrace error. Can anyone tell me what I'm doing wrong ? **Here's my code:** from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait driver = webdriver.Firefox() driver.get("http://dir.indiamart.com/search.mp?ss=plastic+machinery") try: elem = elem = WebDriverWait(driver, 20).until(lambda driver : driver.find_element_by_id('scroll2')) elem.click() print "clicked" except Exception as e: print e driver.close() **Here's the error I'm getting:** Message: Stacktrace: at FirefoxDriver.prototype.findElementInternal_ (file:///tmp/tmpAQcOR7/extensions/fxdriver@googlecode.com/components/driver-component.js:10770) …

Member Avatar
+0 forum 0

Okay so my code is almost complete but I still need one small thing that I can figure out. When running my code it will add 5 when accelerating and subtract 5 when braking, but I need it to display an error when speed >0 when braking, then reset speed back to 0. I know this needs to be done in my def for brake but I can't figure out the proper line of code. Here is my code, thanks for any help. [(http://stackoverflow.com/questions/37124167/need-fixes-for-a-few-errors-python?noredirect=1#comment61836425_37124167)]

Member Avatar
+0 forum 0

![Screenshot_from_2016-05-05_10:40:29.png](/attachments/large/4/d1a3b93ed36e54fabc134d4a3a268ccd.png "align-center") I am trying to write a python code to verify for the presence of `.mp3` and corresponding `.json` file in the dropbox. dropboxmp3txt = self.driver.find_element_by_xpath('//android.widget.ListView/android.view.View/android.widget.TextView[contains(@index, "1")]') print dropboxmp3txt.text This gives me the output : `abc2016-05-05, 10.38.26.mp3` Which is perfectly fine!!! I need the similar xpath to find the `.json` text. The one which is below the `.mp3` , in the figure. I tried doing : dropboxmp3txt = self.driver.find_element_by_xpath('//android.widget.ListView/android.view.View[0]/android.widget.TextView[contains(@index, "1")]') print dropboxmp3txt.text dropboxjsontxt = self.driver.find_element_by_xpath('//android.widget.ListView/android.view.View[1]/android.widget.TextView[contains(@index, "1")]') print dropboxjsontxt.text But, that gave me an error : Traceback (most recent call last): File "dropboxshare.py", line 136, in test_1_view_checkbox dropboxtxt = self.driver.find_element_by_xpath('//android.widget.ListView/android.view.View[0]/android.widget.TextView[contains(@index, …

Member Avatar
+0 forum 0

Am trying to write asimple python programm that harvest data from facebook . like if i type in akey word like "new york" it brings me all events posted on facebook with a connection to newyork.

Member Avatar
-2 forum 0

The End.