filedialog

Java GetFile returns incorrect filename after using SetFile

♀尐吖头ヾ 提交于 2019-12-12 16:09:50
问题 I have some Java code: public static String getSaveFilePath(String title2) { FileDialog fd = new FileDialog(new Frame(), "Save As...", 1); fd.setFilenameFilter(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".mp3"); } }); fd.setFile(title2 + ".mp3"); fd.setVisible(true); String str3 = fd.getFile(); String str4 = fd.getDirectory(); if (str4 == null) return null; str3 = str3.replace(".mp3", ""); str3 = str3 + ".mp3"; String str5 = str3; File localFile

Only one file type to be accepted

99封情书 提交于 2019-12-11 13:45:03
问题 from tkinter import filedialog as fd filename = fd.askopenfilename(title = "Select file",filetypes = (("CSV Files","*.csv"),("All","*.*"))) Opens the folder to choose the file, but when I try: from tkinter import filedialog as fd filename = fd.askopenfilename(title = "Select file",filetypes = ("CSV Files","*.csv")) Error: Traceback (most recent call last): File "D:\python_projects\csv_codes\csv_reading.py", line 4, in filename = fd.askopenfilename(title = "Select file",filetypes = ("CSV Files

How to write data to a file in Hindi language?

点点圈 提交于 2019-12-11 04:29:03
问题 I am trying to write data to a file in a non-roman script using python tkinter. I want to write data to a file in Hindi language which follows the Devanagari Script. While, it is working perfectly alright when I write some data in English, while writing to the file in Hindi language is throwing some errors. How do I resolve this issue? I tried adding (encoding='utf-8') in filedialog command. Doing this, it gives the following error: _tkinter.TclError: bad option "-encoding": must be

Specify File path in tkinter File dialog

江枫思渺然 提交于 2019-12-11 04:23:04
问题 I have a file dialog to open a file, however, the file that I want to open is in a different directory than the program I wrote. The file dialog opens to the directory where I am. Is there a way to specify where the filedialog opens? Here is the relevant code: root = Tk() root.fileName = tkFileDialog.askopenfilename() f = open(root.fileName, 'r') I tried adding the path that I want into the "askopenfilename" call, but that didn't work: root.fileName = tkFileDialog.askopenfilename('/C:') 回答1:

Qt's FileDialog defaultSuffix not functionning

孤人 提交于 2019-12-11 02:32:24
问题 I'm using the following code to the new property of the filedialog under QtQuick.Dialogs 1.3 & Qt 5.10.0. I've build it using Qt Creator 5.10 default kit. import QtQuick 2.10 import QtQuick.Window 2.2 import QtQuick.Dialogs 1.3 Window { visible: true width: 640 height: 480 title: qsTr("Hello World") FileDialog { id: fileDialog title: "Please choose a file" folder: shortcuts.home defaultSuffix: "txt" selectExisting: false selectMultiple: false onAccepted: { console.log("You chose: " + fileUrl)

File download dialog IE7 disappears

陌路散爱 提交于 2019-12-10 11:17:55
问题 The following code will not run correctly in IE7 with the latest service packs installed. System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.Clear(); response.AddHeader("Content-Disposition", "attachment;filename=Contacts.xls"); response.ContentType = "application/octet-stream"; System.Text.UnicodeEncoding Encoding = new System.Text.UnicodeEncoding(); byte[] unicodeBytes = {255,254}; int length = 2 + Encoding.GetByteCount(_exportContent); // _exportContent is

How to show java FileDialog in Front of Google Dev Tools (AlwaysOnTop does not work)

大憨熊 提交于 2019-12-08 13:44:31
问题 I try to use following Java method to open a file selection dialog on top of all other windows (Windows7, Java 11). However, the dialog is shown behind my Google Chrome Dev tools. protected String result(String initialDirectory) { var fileDialog = new FileDialog(getFrame(), "Choose a file", FileDialog.LOAD); fileDialog.setIconImage(getDialogIcon()); if (initialDirectory!=null) { fileDialog.setDirectory(initialDirectory); } fileDialog.setFocusable(true); fileDialog.setLocationByPlatform(true);

Is it possible to prevent file dialog from appearing? Why?

巧了我就是萌 提交于 2019-12-07 10:10:29
问题 Suppose I have input[type=file] element and I want to intercept onclick event and prevent file dialog from appearing if conditions are not met. Is it possible? And why, if - not? 回答1: Soufiane's code requires that you have a Javascript library called jQuery on your page. If you don't have it, you can get it at http://www.jquery.com or use something in plain Javascript: HTML <input type="file" id="openf" /> JS: document.getElementById('openf').onclick = function (e) { e.preventDefault(); };

improving JFileChooser under Ubuntu 12.04 (GTK)

自古美人都是妖i 提交于 2019-12-07 06:02:55
问题 I have a problem with the JFileChooser under Ubuntu 12.04. I use this code to set the look and feel: javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName()); And it looks like this. It's very uncomfortable to use and it looks very ugly: http://www9.picfront.org/token/9sRH/2012/05/15/2062476.jpg I would like it to look like this: http://www4.picfront.org/token/1lpa/2012/05/15/2062477.jpg Using the hint from this post, I tried to use FileDialog instead of the

File download dialog IE7 disappears

巧了我就是萌 提交于 2019-12-06 04:34:06
The following code will not run correctly in IE7 with the latest service packs installed. System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.Clear(); response.AddHeader("Content-Disposition", "attachment;filename=Contacts.xls"); response.ContentType = "application/octet-stream"; System.Text.UnicodeEncoding Encoding = new System.Text.UnicodeEncoding(); byte[] unicodeBytes = {255,254}; int length = 2 + Encoding.GetByteCount(_exportContent); // _exportContent is string. response.AddHeader("Content-Length", length.ToString()); response.OutputStream.Write