Hi everyone well from my last post I found what I am looking for
I have some code now that transfers files
I have added a GUI to it and need some help with two things one my
loadtemplate() function if I run it won't open the filetypes I just get the
error message from tkMessageBox but its the right filetype
and the final problem the Variable FILE how can I get it to interact with
GUI once I select an image to send how can I use the selected File to send
using the sendfile function
this is as far as I know the last of my problems
please note that this code has been taken from different parts of the
internet
Cheers
# USAGE: python FileSender.py [file]
from Tkinter import *
import tkFileDialog
import tkMessageBox
import sys, socket
root = Tk()
root.title("My APP")
root.minsize(30 0, 200)
root.maxsize(50 0, 400)
def loadtemplate():
filename = tkFileDialog.as kopenfilename(f iletypes=(("TIF F", ".tiff"),
("JPG", ".jpg"),
("GIF", ".gif")))
if filename:
try:
self.settings["template"].set(filename)
except:
tkMessageBox.sh owerror("Open Source File", "Failed to read file
\n'%s' " %filename)
return
HOST = 'localhost'
CPORT = 9091
MPORT = 9090
FILE = # I need help here what do I put here
def sendfile():
cs = socket.socket(s ocket.AF_INET, socket.SOCK_STR EAM)
cs.connect((HOS T, CPORT))
cs.send("SEND " + FILE)
cs.close()
ms = socket.socket(s ocket.AF_INET, socket.SOCK_STR EAM)
ms.connect((HOS T, MPORT))
f = open(FILE, "rb")
data = f.read()
f.close()
textbox.insert( "Sending File Now...")
ms.send(data)
ms.close()
textbox.insert( "File Sent now Closing")
mybrowse = Button(root, text="Browse", command=loadtem plate)
mybrowse.grid(r ow=0, column=0, sticky=E+W)
mybutton = Button(root, text="Send File", command=sendfil e)
mybutton.grid(r ow=0, column=1, sticky=E+W)
textbox = Text(root)
textbox.grid(ro w=1, column=0, columnspan=2)
textbox.insert( END, "Depending on size of File this could take a while\n\n") 1 2705
ADE wrote: Hi everyone well from my last post I found what I am looking for
I have some code now that transfers files
I have added a GUI to it and need some help with two things one my loadtemplate() function if I run it won't open the filetypes I just get the error message from tkMessageBox but its the right filetype
The problem is the line: self.settings["template"].set(filename)
This line is out of context. You're not within a class with a "member
variable" called settings. What are you trying to accomplish?
Aren't you looking for somthing like:
....
filename = tkFileDialog.as kopenfilename(f iletypes=(
("TIFF", ".tiff"), ("JPG", ".jpg"),
("GIF", ".gif")))
try:
sendfile(filena me)
except:
tkMessageBox.sh owerror("Some error sending %" % filename)
....
Of course to do so, you need to change the sendfile() function to a
function that takes 'filename' as argument. As a result, there's no
need for a global variable FILE anymore -- which may solve your 2nd problem:
def sendfile(filena me):
...
--
Vincent Wehren This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Limey Drink |
last post by:
Hi all,
Firstly :-) , is there any where I can search through archived newsgroup
posts so I am not cluttering up the newsgroup with repeated queries ?
And secondly :-), I know this has probably been discussed before but.
I am wanting to do some scripting to automate a few administration tasks,
one of the first tasks is automating FTP file transfers.
|
by: Neel Word |
last post by:
I need to develop an application (development platform:
Win2000; target platform: Win98/ME/NT4/2000/XP), which
would require file transfer functionality over dial-up and
network.
We could develop on .NET (1.1 or 1.0 - VS.NET 02/03) or
using plain COM (visual c++). We'd prefer .NET though.
Does anyone know of any products or COM API (or .NET
classes) that can easily handle file transfer over dial-up
|
by: GrantS |
last post by:
I need urgent help. Done OK for a newbie getting automation of Windows
Messenger into a Winform C# app but have three problems that I
urgently need pointers to. Point 1 and 2 are the same issue, I think.
Point 3 might relate to a threading issue:
1. I have written a C# Winform application that uses Windows messenger
automation.
When I attempt to send a file through the window messenger object,
there is some horrid screen flicking...
|
by: SI |
last post by:
I need to transfer a file from a central computer(Windows XP) to multiple 'branch' computers(WindowsNT/Windows2000) on a weekly basis. This transfer should be done programmatically in C#, when a user clicks a button or a menu item. After the transfer, we need to run a Script/batch file on each client computers. The problem is none of these computers are connected to the internet, but they have modems and can connect to telephone lines.
We...
|
by: Abhishek |
last post by:
I have a problem transfering files using sockets from pocket pc(.net compact
c#) to desktop(not using .net just mfc and sockets 2 API). The socket
communication is not a issue and I am able to transfer data across.On the
serve I am using Socket 2 API (recv function to read bytes)and not using
..NET. I use FileStream to open the file on the pocket pc, then associate a
BinaryReader object with the stream and call ReadBytes to read all the...
| |
by: Thomas Connolly |
last post by:
I have 2 pages referencing the same codebehind file in my
project. Originally the pages referenced separate code
behind files. Once I changed the reference to the same
file, everything worked fine while the file was in the
project directory. When the obsolete file was removed
from the project directory, my application will no longer
compile. Can someone please help with this issue?
Thank in advance,
Tom
|
by: Jay |
last post by:
Hi,
I have some unique situations where i need to transfer a file from
Server to client but without any Open or Save dialog box shown to the
user. The file should save itself directly to client machine.
I want to transfer word (.doc) file from server to client without
open/save dialog box.
Transfer of file should be silent and invisible to client.
|
by: Jay |
last post by:
Hi,
I have some unique situations where i need to transfer a file from
Server to client but without any Open or Save dialog box shown to the
user. The file should save itself directly to client machine.
I want to transfer word (.doc) file from server to client without
open/save dialog box.
Transfer of file should be silent and invisible to client.
|
by: krishan123456 |
last post by:
i have tried to send email with attached doc file but when i receive the mail i find the attached file in encoded text instead of actuall attachment.the code that i used to send an email is given below.
function SendMail123($From,$FromName,$To,$ToName,$Subject,$Text,$Html,$AttmFiles){
$OB="----=_OuterBoundary_000";
$IB="----=_InnerBoundery_001";
$Html=$Html?$Html:preg_replace("/\n/","{br}",$Text)
or die("neither text nor...
|
by: David |
last post by:
I have googled to no avail on getting specifically what I'm looking for. I
have found plenty of full blown apps that implement some type of file
transfer but what I'm specifcally looking for is an example to follow for
using a tcp socket to transfer files between client/server, server/client.
Both server and client are my program so I'm not looking for how to
implement an FTP client, or how to download a file from a web server via
http...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |