Discuss Scratch

MonkeyBean2
Scratcher
100+ posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

Can I be a helper?

Last edited by MonkeyBean2 (June 29, 2022 20:14:41)



9NAwRfSR-%dWFS$a$g&zBMTj2?;jvS?L5%^X%qpCX|A<*paJ=lU07c)wmt$v{TxL5



scratchGui.timeTravel.year = '2020'
Joshisaurio
Scratcher
100+ posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

ScratchTheCoder12345 wrote:

ScratchTheCoder12345 wrote:

Can I be a helper? I'm very advanced with Python.
bump
Please wait longer to bump your posts, about 1 day


Banner by @NFlex23


Banner by @NFlex23

Joshisaurio
Scratcher
100+ posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

MonkeyBean2 wrote:

I want to be a helper! - Can I be a helper? I'm quite advanced with Python.
Sure! Also about your double post please be patient it takes me a while to post because of the 60 second post wait


Banner by @NFlex23


Banner by @NFlex23

ScratchTheCoder12345
Scratcher
500+ posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

Any help needed? Feel free to message me here or on my profile!

Hello, I'm Brandon a Python developer who loves math and coding.
he/him
Feel free to message me with any questions
Joshisaurio
Scratcher
100+ posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

MonkeyBean2 wrote:

Can I be a helper?
What code editors do you use?


Banner by @NFlex23


Banner by @NFlex23

mzarony0
Scratcher
48 posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

I have yet another question. I am trying to create a program that allows the user to first write down whatever they want, and then download it (kind of like a small notepad). I have figured everything out other than the downloading part. Is there a built in function to download or is there a library? Thanks!

Last edited by mzarony0 (June 29, 2022 20:31:43)


It's easy to play any musical instrument: all you have to do is touch the right key at the right time and the instrument will play itself.
-Bach
have a nice day

Dinosu
Scratcher
77 posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

mzarony0 wrote:

I have yet another question. I am trying to create a program that allows the user to first write down whatever they want, and then download it (kind of like a small notepad). I have figured everything out other than the downloading part. Is there a built in function to download or is there a library? Thanks!
It depends on how you're doing things. Are you using the input() function to get the user's input in the console, and have you worked with text files before?
mzarony0
Scratcher
48 posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

Dinosu wrote:

mzarony0 wrote:

I have yet another question. I am trying to create a program that allows the user to first write down whatever they want, and then download it (kind of like a small notepad). I have figured everything out other than the downloading part. Is there a built in function to download or is there a library? Thanks!
It depends on how you're doing things. Are you using the input() function to get the user's input in the console, and have you worked with text files before?
yes and yes

It's easy to play any musical instrument: all you have to do is touch the right key at the right time and the instrument will play itself.
-Bach
have a nice day

Dinosu
Scratcher
77 posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

mzarony0 wrote:

Dinosu wrote:

mzarony0 wrote:

I have yet another question. I am trying to create a program that allows the user to first write down whatever they want, and then download it (kind of like a small notepad). I have figured everything out other than the downloading part. Is there a built in function to download or is there a library? Thanks!
It depends on how you're doing things. Are you using the input() function to get the user's input in the console, and have you worked with text files before?
yes and yes
So I suppose the question is that you've loaded the user's input into the text file and want to download that file automatically. You have a few options for accomplishing this, and this article should help you choose one.

Edit: the way this works also depends on the IDE. I believe the article I just referenced only works in Replit, because it is the only IDE we have listed in this topic that provides support for a web-based file created by a program. Sorry, I overlooked the question when I was answering; I'm sure there's a better way.

Last edited by Dinosu (June 29, 2022 20:49:01)

MonkeyBean2
Scratcher
100+ posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

mzarony0 wrote:

I have yet another question. I am trying to create a program that allows the user to first write down whatever they want, and then download it (kind of like a small notepad). I have figured everything out other than the downloading part. Is there a built in function to download or is there a library? Thanks!

Well, i'm not sure what you mean by ‘download’ exactly, but this is how you write/read files:


# write to file:
with open("file.txt", "w") as f:
    f.write("I wrote something to a file!!! YAY!!!")
#
#
# append to file (add more stuff to the end of a file):
with open("file.txt", "a") as f:
    f.write("I appended something! :D")
#
#
# read file:
with open("file.txt", "r") as f:
    print(f.read())


9NAwRfSR-%dWFS$a$g&zBMTj2?;jvS?L5%^X%qpCX|A<*paJ=lU07c)wmt$v{TxL5



scratchGui.timeTravel.year = '2020'
ScratchTheCoder12345
Scratcher
500+ posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

MonkeyBean2 wrote:

mzarony0 wrote:

I have yet another question. I am trying to create a program that allows the user to first write down whatever they want, and then download it (kind of like a small notepad). I have figured everything out other than the downloading part. Is there a built in function to download or is there a library? Thanks!

Well, i'm not sure what you mean by ‘download’ exactly, but this is how you write/read files:


# write to file:
with open("file.txt", "w") as f:
    f.write("I wrote something to a file!!! YAY!!!")
#
#
# append to file (add more stuff to the end of a file):
with open("file.txt", "a") as f:
    f.write("I appended something! :D")
#
#
# read file:
with open("file.txt", "r") as f:
    print(f.read())
They mean download something to your device like download random_file.txt to your computer's hard drive.

Hello, I'm Brandon a Python developer who loves math and coding.
he/him
Feel free to message me with any questions
Dinosu
Scratcher
77 posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

mzarony0 wrote:

Dinosu wrote:

mzarony0 wrote:

I have yet another question. I am trying to create a program that allows the user to first write down whatever they want, and then download it (kind of like a small notepad). I have figured everything out other than the downloading part. Is there a built in function to download or is there a library? Thanks!
It depends on how you're doing things. Are you using the input() function to get the user's input in the console, and have you worked with text files before?
yes and yes

I have never downloaded a local file using Python, but it seems unnecessary considering that the file is already created on the user's computer. In general, whether you're running a program in Pycharm, Replit, Jupyter, etc., when you create a text file in your program, it will be saved in the same directory as the script. If you're running your program on an IDE local to your computer, such as Pycharm, your file will already be on your computer, but you can do things like move it to your documents folder.

If you're running something over the Internet, such as in Replit, you can manually click download on the created file, or use the option I theorized above.
applejuiceproduc
Scratcher
1000+ posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

Joshisaurio wrote:

applejuiceproduc wrote:

I use VSCode, vi and replit
Ok but what's vi?
Vi is one of the first and most important text editors, more info here.

A signature
mybearworld
Scratcher
1000+ posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

Joshisaurio wrote:

Ok but what's vi?
vi

Signatures are the only place where assets links still work.
DifferentDance8
Scratcher
1000+ posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

mzarony0 wrote:

I am trying to create a program that allows the user to first write down whatever they want, and then download it (kind of like a small notepad).
If you use tkinter, then it is as simple as:
tkFileDialog.asksaveasfile(mode="w", defaultextension=".txt")
code totally not stolen from stackoverflow

Forums were down, now they're not!
NFlex23
Scratcher
1000+ posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

New banner requested by @Joshisaurio:


Banner by NFlex23

Please use this BBCode for it and leave the credit in place:
[img]https://assets.scratch.mit.edu/get_image/.%2E/f831be213f6f518c4cf3801129854032.png[/img]
[small][i]Banner by [url=https://scratch.mit.edu/users/NFlex23]NFlex23[/url][/i][/small]

Last edited by NFlex23 (June 30, 2022 11:47:10)


Help improve the Advanced Topics (Really!)
Before you create a topic:
Always search for duplicates or other similar topics before making an umbrella topic, e.g., “The Mac Topic”.
  • Is it about something you are planning on making but haven't made yet? If so, please wait to post until you have created a working prototype. This is a key factor to keeping the ATs as clean as possible.
  • The ATs aren't technical support. It is perfectly valid to ask questions about things related to programming, but not issues with external websites, apps, or devices. Most sites have their own support system; try asking there!
  • Is it related to something you are making in Scratch? (This includes OSes and other Scratch projects) If so, please post in Collaboration, Show and Tell, or another similar forum.
  • Is your topic questionably “advanced”? Try browsing the other forums to see if your topic fits better in one of those.
  • Issues with Scratch itself should be put in Bugs and Glitches.
Before you post: Is what you're posting likely to start an argument or derail the thread (e.g., browsers, operating systems)? If so, please re-think your post!





MonkeyBean2
Scratcher
100+ posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

DifferentDance8 wrote:

mzarony0 wrote:

I am trying to create a program that allows the user to first write down whatever they want, and then download it (kind of like a small notepad).
If you use tkinter, then it is as simple as:
tkFileDialog.asksaveasfile(mode="w", defaultextension=".txt")
code totally not stolen from stackoverflow

That brings up the file picker dialogue, opens the file you select, and can be treated similarly to
open("file path", "mode")


Example:
import tkinter as tk
from tkinter import filedialog
root = tk.Tk()
root.withdraw()
# here, we replace open("file.txt", "w") with tkinters function
with filedialog.asksaveasfile(mode="w", defaultextension=".txt") as f:
     f.write("blablahblah")


9NAwRfSR-%dWFS$a$g&zBMTj2?;jvS?L5%^X%qpCX|A<*paJ=lU07c)wmt$v{TxL5



scratchGui.timeTravel.year = '2020'
MonkeyBean2
Scratcher
100+ posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

ScratchTheCoder12345 wrote:

They mean download something to your device like download random_file.txt to your computer's hard drive.

Saying “download” usually means getting data from another computer.


9NAwRfSR-%dWFS$a$g&zBMTj2?;jvS?L5%^X%qpCX|A<*paJ=lU07c)wmt$v{TxL5



scratchGui.timeTravel.year = '2020'
ScratchTheCoder12345
Scratcher
500+ posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

DifferentDance8 wrote:

mzarony0 wrote:

I am trying to create a program that allows the user to first write down whatever they want, and then download it (kind of like a small notepad).
If you use tkinter, then it is as simple as:
tkFileDialog.asksaveasfile(mode="w", defaultextension=".txt")
code totally not stolen from stackoverflow
hahan stack overflow

Hello, I'm Brandon a Python developer who loves math and coding.
he/him
Feel free to message me with any questions
MagicCrayon9342
Scratcher
1000+ posts

PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |

ScratchTheCoder12345 wrote:

DifferentDance8 wrote:

mzarony0 wrote:

I am trying to create a program that allows the user to first write down whatever they want, and then download it (kind of like a small notepad).
If you use tkinter, then it is as simple as:
tkFileDialog.asksaveasfile(mode="w", defaultextension=".txt")
code totally not stolen from stackoverflow
hahan stack overflow
You can take a look at the sources of AuraPad. A Python text editor written entirely in Python. Or if you want, just fork it!

Last edited by MagicCrayon9342 (June 30, 2022 15:05:33)


Powered by DjangoBB