I have been wrestling with this for two days now and getting nowhere. Something is broken, either the GridSizer control or me. I'm hoping it's me and someone can show me the problem. I've stripped my app of non-essentials. What I am building is a Sudoku app which consists of several nested controls, as can be seen in the atached image. The outer frame contains the puzzle which contains a 3x3 grid of panes. Each pane contains a 3x3 grid of tiles and each tile contains a 3x3 grid of digits. So far so good. Except for the layout. I …

Member Avatar
Member Avatar
+0 forum 1

Hi all, I have 2 form and a main.py in the project: ffrend.py and fmain.py main.py: from PyQt4 import QtCore, QtGui from fmain import * if __name__ == "__main__": import sys app = QtGui.QApplication(sys.argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow() ui.setupUi(MainWindow) MainWindow.show() app.exec_() fmain.py (there is a button to execute the following function) def friendNetWork(self): form = QtGui.QWidget() ui = Ui_ffriend() ui.setupUi(form) form.show() app.exec_() When I run main.py, the fmain form is shown. When I click the button on fmain form, the friendNetWork will be executed and create another widget. But...I received the error in console :(...And the python is …

Member Avatar
Member Avatar
+0 forum 6

Hi, I have a .csv file in an AWS machine i wanted to convert that .csv file to .dat file? Can you please help me? Thansk, Swetha. G

Member Avatar
Member Avatar
+0 forum 2

I'm having a problem with my python installation. The packages that came with the installation work just fine but when I try to use other installed packages I run into problems. For example, I installed a package `pymsgbox` using pip from an admin shell. When I run a sample script from the command line as in `sample`, I get ModuleNotFoundError: No module named 'pymsgbox' but when I run it by `python sample.py` it works fine. Likewise if I load it into IDLE and run it from there. Suggestions?

Member Avatar
Member Avatar
+0 forum 8

Because Microsoft will be removing vbScript in the next version of Windows, I have been busy converting my utility vbScripts into Python. Part of this is a library of functions that I keep in `D:\include`. I'd like to maintain this system in Python, but the import process is rather clumsy. I have to import sys sys.path.insert(0,r'D:\include') Only after that can I import a file. The documentation is somewhat obtuse but I gather my best option is to add the file `D:\include__init__.py`. As long as that folder is known to Python I could then do from include import myfile1 to include …

Member Avatar
Member Avatar
+0 forum 5

Have two CSV files containing client records and need to compare the two and then output to a third file those rows where there are differences to the values within the record (row) as well as output those records (rows) on the second file that are not on first file . Example: File 1: KeyField,Name,City, Zip,Location 123,Fred,Chicago,60558,A2 234,Mary,Orlando,12376,4L6 345,George,Pittsburgh,40567, 22 456,Peter,Topeka,00341,234 567,Doc,Birmingham,76543,H86 File 2: KeyField,Name,City,Zip,Location 123,Fred,Chicago,60558,A2 234,Mary,Orlando,12376,4L6 345,George,Boston, 40567,22 456,Peter,Topeka,00341,234 567,Doc,Birmingham,7654,H86 678,Isabel,Guadalajara,87654,M111 The results should create a file containing : 345,George,Boston,40567,22 678,Isabel,Guadalajara,87654,M111 The following code gets me in the neighborhood as a visual check: import os import difflib f=open('original.csv','r') #open …

Member Avatar
Member Avatar
+0 forum 10

Hello, I found this code in a thread from about 18 months ago in a post by 'woooee' - [CODE]def func_1(): print " func_1 test" def func_2(): print " func_2 test" def func_3(): print " func_3 test" def func_4(): print " func_4 test" ##---------------------------------------------------------------- ## dictionary = list of function to call and menu choice to print menu_d = { 1:['func_1()', '1)Load'], 2:['func_2()', '2)Save'], 3:['func_3()', '3)Add Phone Number'], 4:['func_4()', '4)View Phone Number'], 5:["", "5)Exit"]} choice = 0 while choice != 5: print "\nSelect an Option\n" for j in range(1, 6): print menu_d[j][1] ## print list's element #1 for key=j choice …

Member Avatar
Member Avatar
+0 forum 8

Hello all, I was wondering if I could get some questions answered about how cupons work in the work place. I have an idea which involves creating a very flexible cupon service, but would require knowing the rudiments of how cupons work. The main question I have is how is tax calculated on a ware as it is sold under a cupon service. I believe that would be the only thing I would have to stringently mandate as far as the cupon goes, since the institution wishes to clear the merchendise from the floor. The service would involve some C# …

Member Avatar
Member Avatar
+0 forum 3

![code_error.png](/attachments/large/4/0618569524bcc2abec40e81e5691d469.png) I'm relatively new to python, and I'm trying to create a pokemon battle. This error has come up, I've looked up solutions but it hasn't helped me as I can't understand it properly. Please help, I'd like to learn especially since I'm planning on taking IT and computer science for GCSEs. Thank you in advance.

Member Avatar
Member Avatar
+0 forum 5

Is it possible to store a certain function as a variable? If not, is it okay to make a class, and define a function. Store the class as the variable and invoke that function?

Member Avatar
Member Avatar
+1 forum 7

hi there i have some python coding which i need to convert to java can ne1 help me please email me back if you can help then i will show you the coding much appriciated

Member Avatar
Member Avatar
+0 forum 8

[B]Hi all.. I need to do a condition check in a script. The same condition check needs to be repeated in another script. So, I am looking for a way, where i can set, say a flag in the first script ,upon meeting the condition, and be able to access that flag in another script, instead of repeating the check all over again. Hope I am clear in explaining what I want to do. Can anyone pls give me suggestions? [/B]

Member Avatar
Member Avatar
+0 forum 13

Hello fellow python lovers of daniweb.com. This isn't as much a question as much as the fact that I want to see how different people would go about using python to inject an SQl database. I made a script were you can access the ip and run a command. NOTE:Obviously I didn't give an actual database. Who am I kidding you guys aren't stupid. Here's my injection script import MySQLdb db = MySQLdb.connect(host="localhost", # your host, usually localhost user="USER", # your username passwd="PWD", # your password db="MySQLdb") # name of the data base # you must create a Cursor object. …

Member Avatar
Member Avatar
+0 forum 4

Fellow Python developers, Python has a sorted() or sort() function to implement ascending or descending order programs,but supposing if i want to develop a ascending order program that takes user input and ascends or descends them,how should I go about? For Example: Lets Say i want to convert this C program to Python? # include <iostream.h> # include <conio.h> void main() { int a[10],i,j,n,temp; clrscr(); cout<<"\nEnter n nos: "; cin>>n; cout<<"\nEnter the numbers: "; for(i=0;i<n;i++) cin>>a[i]; for(i=0;i<n;i++) for(j=i+1;j<n;j++) { if(a[i]>a[j]) { temp=a[i]; a[i]=a[j]; a[j]=temp; } } for(i=0;i<n;i++) cout<<a[i]<<endl; getch(); } This is an ascending order program in C. Thanks in …

Member Avatar
Member Avatar
+0 forum 4

Hi i have been spending the last few days deciding on an IDE that would let me program in Java, C++ and python and notepad++ looked pretty good. The only issue is i cant work out how to make the program run once i have made it. I looked in google and i couldn't find any tutorials to set it for python but if anyone could help that would be greatly appreciated. Thanks!

Member Avatar
Member Avatar
+1 forum 8

Hi, i was working on a code for a vending machine and i do consider myself to be a beginner, anyway i feel my code is much longer than it needs to be and i want someone to show me a new, shorter way of presenting it. import time print ("Welcome to the Python Vending Machine.") # Asking the user how much money they wish to enter. number_of_10p = int(input("How many 10 pence coins would you like to insert? ")) while number_of_10p < 0: number_of_10p = int(input("Please enter a positive number.")) number_of_20p = int(input("How many 20 pence coins would you …

Member Avatar
Member Avatar
+0 forum 5

Hi, i wasn't sure about the title of my question, hope its okay. Anyway, the program i have is suppose to read a binary file then find for specific bytes like this: bytes1 = bytearray(b'\x41\x64\x6F\x62\x65\x20') filename = "portrait1.dng" with open(filename, "rb") as binaryfile: with open("foundhex.txt", "w") as found: found.write("File that is analysed : " + filename + "\n") found.write("Date of analysis : " + str(today) + "\n") while True: read_file = bytearray(binaryfile.read(1024)) find_bytes1 = read_file.find(bytes1, 0) if fine_bytes1 != -1: with open("foundhex.txt", "a") as found1: found1.write("Found 41646F626520 at : " + str(find_bytes1) + "\n") if not read_file: break basically, it …

Member Avatar
Member Avatar
+0 forum 3

Hello. I got one question, when i want to streamplot this, i got eror: "raise ValueError("The columns of 'y' must be equal")", i can't figure it out. :/ Thank you for your time. this is entire code: import matplotlib.pyplot as plt import numpy as np # discretization of domain x_start, x_end = 0. , 10. y_start , y_end = 0. , 8. i = np.linspace(x_start, x_end, 80) j = np.linspace(y_start, y_end, 50) X,Y = np.meshgrid(i,j) Y[:,:40] += 1 Dx = x_end/(np.size(i)-1) Dy = y_end/(np.size(j)-1) beta = Dx/Dy nx = np.size(i) #number of points on x axis ny = np.size(j) #number …

Member Avatar
Member Avatar
+0 forum 1

Hi all, The continuing quest to master Tkinter has led to this implementation of the dots and boxes game. The rules are well-known: each player gets to create a new line between two dots (single-click near the line you wish to create). If a player creates a box, he gets a point *and* gets to go again. (Two boxes gets two points, but only one extra turn.) The highest score out of 81 boxes wins! Please feel free to mercilessly criticize the UI or the code; I'm looking to improve it and submit to the Code Snippets thread. Thanks, Jeff …

Member Avatar
Member Avatar
-1 forum 5

import tkinter root = tkinter.Tk() root.geometry("200x200") buttons=[i for i in range(10)] def getNext(): #If specific button is pressed, output "YES" for num in buttons: btn=tkinter.Button(root, text=num,command=getNext) btn.pack(side=tkinter.TOP)

Member Avatar
Member Avatar
+0 forum 1

I want to associate a REST API end point to two urls, "manager" and "manager/". So I added two path entries in the urlpatterns with these urls. But it seems something that can be handled with some kind of configuration. Is there such a configuration with django? thanks

Member Avatar
Member Avatar
+0 forum 1

hi. i have a really basic question (really new to python). how do i read an entire binary file? from https://www.devdungeon.com/content/working-binary-data-python , `data = binary_file.read()` is to read the whole file at once. so i have a .dng file to test, which is 16.2mb, and i did: with open("portrait1.dng", "rb") as binary_file: #Read the whole file at once data = binary_file.read() #Return the hexadecimal representation of the binary data, byte instance hexa = binascii.hexlify(data) with open("readprotrait1.raw", "wb") as write_file: write_file.write(hexa) im using a hex editor to see if the data from .dng gets copied to the .raw file but only …

Member Avatar
Member Avatar
+0 forum 2

This is my custom module: [CODE]class Player(object): def __init__(self, name, score = 0): self.name = name self.score = score def __str__(self): rep = self.name + ":\t" + str(self.score) return rep def ask_yes_no(self, question): response = None while response not in ("y", "n"): response = input(question).lower() return response def ask_number(self, question, low, high): response = None while response not in range (low, high): response = int(input(question)) return response[/CODE] The program: [CODE]import games, random print "Welcome to the world's simplest game!\n" again = None while again != "n": players = [] num = games.ask_number(question = "How many players? (2-5): ", low = …

Member Avatar
Member Avatar
+0 forum 10

Hi. I have a .raw file and I want to display it as hex. why? because i want to try and replicate what 010 Editor can do which is read any sort of file and display in whatever format user desires (plus it can be used to edit and stuff) but I'm focusing on .raw files only and to display in hex only. i sort of understand that binascii.hexlify() returns the hexadecimal representation of the binary data (.raw files are binary data right?) but when i do : content = open(fileName, "rb") byte = content.read(1) hexadecimal = binascii.hexlify(byte) self.file_content.setText(hexadecimal) I …

Member Avatar
Member Avatar
+0 forum 8

Hello all, i need your help regaring this code, which is in python and i need to convert it into mips?? register $s0 holds the base address of list my_data, $s1 holds the length of the list my_data, register $s2 holds the base address of list my_data2 and $s3 holds the length of the list my_data2. def sum_to_x(x): sum = 0 for i in range (x): sum += i return sum my_data = [1, 3, 6, 7] my_data2 = [2, 1, 5] for i in range( len( my_data ) ): my_data[ i ] = sum_to_x( my_data[ i ] ) for …

Member Avatar
Member Avatar
-1 forum 6

If you're in one of those predicaments where `cls.__private` attributes just aren't enough since they can easily be accessed through `inst._cls__private`, and you need something a little more secure, here's a method I've been playing with for a while that fills that gap. Note that this uses `__slots__`, more info on this below the code. def private(): # no outside access class A(object): __slots__ = ['__private__'] def __init__( inst, val=None ): setprivate( inst, val ) def __repr__( inst ): return '<A %s >' % getprivate( inst ) globals()['A'] = A # add our class to the public namespace dsc = …

Member Avatar
Member Avatar
+0 forum 1

Hi guys have a python software that i want to freeze for distribution. The problem is after freezing it with cx_freeze and i run it, it works fine on my development computer but when i sent it to my testing computer (window XP sp3 32bit) it give me this error Traceback(mostresent call last): File "C:Python27\lib\site-packages\cx_Freeze\initscripts\Console.py", line27, in <module? File "timeTracker.py", line 555, in <module> File "timeTracker.py", line 381, in __init__ File "timeTracker.py", line 427, in runTimeThread File "timeTracker.py", line 494, in __init__ File "timeTracker.py", line 118, in __init__ File "C:Python27\lib\site-packages\pyttsx1.1-py2.7.egg\pyttsx\__init__.py", line 39, in init File "C:Python27\lib\site-packages\pyttsx1.1-py2.7.egg\pyttsx\engine.py", line 45, in __init__ …

Member Avatar
Member Avatar
+0 forum 9

How to write pseudocode in python

Member Avatar
Member Avatar
+0 forum 3

Guys, I am trying to change the background color of my window in WxPython. Here is what I got: Why doesn't it work? [CODE]import wx class my_window(wx.Frame): def __int__(self, parent, id): wx.Frame.__int__(self,parent,id,'My Window', size=(300,200)) self.Colours() def Colours(self): self.pnl1.SetBackgroundColour(wx.BLACK) if __name__ == "__main__": app=wx.PySimpleApp() frame=my_window(parent=None,id=-1) frame.Show() app.MainLoop()[/CODE]

Member Avatar
Member Avatar
+0 forum 5

Hello, everybody. I was wondering if anybody could help me with something. I don't know if I'm taking things too fast but, I was wondering if somebody could help with this program I am making. I'm currently writing a "fake" bank script. Basically you start with a set amount of money, and you can deposit it, withdraw it, and check your balance. However, when I make the deposit and then check my balance, I shows up as the balance being 0, instead of what I had deposited... Could somebody help me out?? Here's the code: Bank.pyw: [CODE]#THIS PART IS NOT …

Member Avatar
Member Avatar
-1 forum 13

The End.