• ベストアンサー
※ ChatGPTを利用し、要約された質問です(原文:wxpythonの文法(ファイル参照ダイアログ))

wxPythonのファイル参照ダイアログの使い方を教えてください

wettiの回答

  • wetti
  • ベストアンサー率66% (2/3)
回答No.1

オブジェクト指向は使わなくても書けるっす。 http://codepad.org/ywov67Fk ただし、ソースコードが激しくスパゲッティ化するけどね。 それから、この程度の内容であれば wxPythonじゃなくてtkinterでもいいような気がする。 GUIライブラリが鎬を削るPython界において、 Python3対応の遅れているwxPythonは今後もずっと使えるかどうか不安なんすよ。 あと、プログラミングの質問をするときは、 使用しているインタープリタやらライブラリやらのバージョンと、 OSの種類をきちんと書いてください。 OSやバージョンによって書き方や説明が違う場合もあるし、 それらをいちいち調べて回るのも面倒なんで。

関連するQ&A

  • JavaのSwingのレイアウト

    Swingを学習中ですが、うまくレイアウトできません。 添付した画像のようなレイアウトにしたいです。 作ってみたものは以下です。 import java.awt.BorderLayout; import java.awt.Color; import javax.swing.*; public class LayoutTest { public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); JTextField searchFiled = new JTextField("テキスト"); String[] comboboxString = {"C", "C++", "Java"}; JComboBox comboBox = new JComboBox(comboboxString); JButton button = new JButton("ボタン"); panel.add(comboBox, BorderLayout.EAST); panel.add(searchFiled, BorderLayout.CENTER); panel.add(button, BorderLayout.WEST); frame.add(panel, BorderLayout.PAGE_START); JPanel redPanel = new JPanel(); redPanel.setBackground(Color.RED); frame.add(redPanel); frame.setSize(700, 500); frame.setLocationRelativeTo(null); frame.setVisible(true); } }

    • ベストアンサー
    • Java
  • GridLayoutのPanel上のButton

    GridLayoutのPanel上のButton横サイズを取得したいのですが、 button1.getWidth()==0 と出てしまいます。 フレームやパネルのサイズをボタン数で割れば出るのですが、 そうではなく、ボタンのサイズを取得したいです。 ご存知の方がおられましたら教えて下さい。 //----以下ソースです---- import java.awt.Dimension; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class ButtonSizeOnGridLayout extends JFrame { public ButtonSizeOnGridLayout() { JPanel panel1 = new JPanel(new GridLayout(0, 5)); JButton button1 = new JButton(); button1.setPreferredSize(new Dimension(150, 150)); System.out.println("button1.getWidth()==" + button1.getWidth());//出力:0 panel1.add(button1); this.getContentPane().add(panel1); this.pack(); this.setVisible(true); } public static void main(String a[]) { new ButtonSizeOnGridLayout(); } }

    • ベストアンサー
    • Java
  • JButtonの配置

    FlowLayoutによって、JFrameにボタン6個を2×3に配列するプログラムを考えています。ボタンを配置することはできたのですが、ウインドウの大きさを変えるとボタンが3×2になったりと変更してしまいます。 ウインドウの大きさを変えても、ボタンの大きさは変えず、ボタン6個が2×3配列になるプログラムはどうしたらよいのでしょうか?以下は、途中のプログラムです。 import java.awt.*; import javax.swing.*; public class sample { public static void main(String[] args){ MyFrame frame = new MyFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } public class MyFrame extends JFrame { public static final int WIDTH = 200; public static final int HEIGHT = 300; public MyFrame(){ setSize(WIDTH,HEIGHT); Container contentPane = getContentPane(); MyPanel panel = new MyPanel(); contentPane.add(panel); } } public class MyPanel extends JPanel{ public static final int MESSAGE_X = 200; public static final int MESSAGE_Y = 200; setLayout(new FlowLayout()); JButton button1 = new JButton("Button1"); contentPane.add(button1); JButton button2 = new JButton("Button2"); contentPane.add(button2); JButton button3 = new JButton("Button3"); contentPane.add(button3); JButton button4 = new JButton("Button4"); contentPane.add(button4); JButton button5 = new JButton("Button5"); contentPane.add(button5); JButton button6 = new JButton("Button6"); contentPane.add(button6); }

    • ベストアンサー
    • Java
  • cadで作った図面をフレーム上で表示

    こんばんは いつもお世話になっています。 gif形式の図を表示することはできるのですが AutoCADで描いた図はgifファイルに出力できません。 下記のようにコーディングしたのですが、”ぜひお越しください”しか表示されませんでした。 ほかの形式(dxf、wfm、bmp)でもいろいろ試したのですができませんでした。 どうすればAutoCADで作った図をフレーム上に表示できるのでしょうか? どなたか教えていただけませんか? import java.awt.*; import javax.swing.*; import javax.swing.ImageIcon; class map { public static void main(String args[]) { JFrame frame=new JFrame("map test"); JPanel panel=new JPanel(); ImageIcon ico=new ImageIcon("地図.gif"); JButton button=new JButton("ぜひお越しください",ico); panel.add(button); Container ct=frame.getContentPane(); ct.add(panel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } }

  • GUIを使用した電卓のボタンの表示について

    Javaの課題で電卓を制作しています。 まず見た目だけ完成させるべくボタンを配置を配置しましたが、 実行してみると正しく表示されるときと、されないときがあります(画像参照)。 現時点でのコードを掲載いたしますので、是非アドバイスをいただけると幸いです。よろしくお願いします。 ■以下コード package add; import java.awt.Button; import java.awt.Frame; import java.awt.TextField; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; public class Calc extends Frame{ public static void main(String[] args){ Calc frame = new Calc(); } public Calc(){ super("電卓"); setSize(317,360); setVisible(true); addWindowListener(new CalcWindow()); //下記のウィンドウを閉じる用 //ボタンとフィールドの追加 TextField result = new TextField(""); result.setBounds(20,50,270,50); add(result); result.setFocusable(false); Button button1 = new Button("1"); button1.setBounds(20,120,70,30); add(button1); Button button2 = new Button("2"); button2.setBounds(100,120,70,30); add(button2); Button button3 = new Button("3"); button3.setBounds(180,120,70,30); add(button3); Button button4 = new Button("4"); button4.setBounds(20,165,70,30); add(button4); Button button5 = new Button("5"); button5.setBounds(100,165,70,30); add(button5); Button button6 = new Button("6"); button6.setBounds(180,165,70,30); add(button6); Button button7 = new Button("7"); button7.setBounds(20,210,70,30); add(button7); Button button8 = new Button("8"); button8.setBounds(100,210,70,30); add(button8); Button button9 = new Button("9"); button9.setBounds(180,210,70,30); add(button9); Button button0 = new Button("0"); button0.setBounds(100,255,70,30); add(button0); Button buttonC = new Button("C"); buttonC.setBounds(20,255,70,30); add(buttonC); Button buttonasta = new Button("."); buttonasta.setBounds(180,255,70,30); add(buttonasta); Button buttonplus = new Button("+"); buttonplus.setBounds(260,120,30,30); add(buttonplus); Button buttonminus = new Button("-"); buttonminus.setBounds(260,165,30,30); add(buttonminus); Button buttonkakeru = new Button("×"); buttonkakeru.setBounds(260,210,30,30); add(buttonkakeru); Button buttonsla = new Button("/"); buttonsla.setBounds(260,255,30,30); add(buttonsla); Button buttonE = new Button("="); buttonE.setBounds(20,300,270,30); add(buttonE); //ボタンとフィールドの追加ここまで } class CalcWindow extends WindowAdapter //ウィンドウを閉じる { public void windowClosing(WindowEvent e) { System.exit(0); } } } ※OKWAVEより補足:「Webシステム開発」についての質問です。

    • ベストアンサー
    • Java
  • java アプレットでエラー

    以下のサンプルソースをEclipse上で実行したら "アプレットは初期化されていません"というエラーになってしまいました。 //フレームウィンドウの表示/非表示を切り替える。 import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Sample129 extends Applet implements ActionListener { Button bt; frame fr; public void init() { bt = new Button("ウィンドウ表示"); add(bt); bt.addActionListener(this); fr = new frame("操作対象ウィンドウ"); fr.setSize(250,120); } public void actionPerformed(ActionEvent event) { //ウインドウを表示 fr.setVisible(true); } } class frame extends Frame { frame(String title) { super(title); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { //ウインドウを非表示 setVisible(false); } }); } public void paint(Graphics g) { g.drawString("閉じるボタンで非表示",65,65); } } ■エラー内容 java.lang.NoSuchMethodError: frame: method <init>(Ljava/lang/String;)V not found at Sample129.init(Sample129.java:17) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) どうすればこのエラーが解消できるのでしょうか。

  • xcode 画像をランダムに並べ順番に押す

    初めてですが質問よろしくお願いします。 iphone開発初心者です。 数字の画像をランダムに5×5に並べ、1から25まで順番に押していく、 というアプリを制作中なのですが行き詰まっています。 現在下記コードのようになっています。 画像を表示まではできたのですが、下記3つ、できればソースコードをお聞きしたいです。 (1)画像25個をランダムに表示する記述がわかりません (今はとりあえずで同じ画像を1つ入れてます。(img1~img25のimg1を代入中)) (2)順番に押していく処理 (3)画像を押された時に音を出したい - (IBAction)image:(id)sender { AudioServicesPlaySystemSound(sound_1); } の部分をうまく入れこめばいいのかと思っていますが、その入れこみ方もわかりません。 AudioToolboxは追加済みです。 どなたかご教授よろしくお願いします。 #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. NSString *path = [[NSBundle mainBundle] pathForResource:@"btn_1" ofType:@"mp3"]; NSURL *url = [NSURL fileURLWithPath:path]; AudioServicesCreateSystemSoundID((CFURLRef)CFBridgingRetain(url), &sound_1); int yo = 5; for(int i = 0;i<yo; i++){ UIImageView *imageView = [UIImageView new]; imageView.frame = CGRectMake(15+60*i, 100, 60, 60); imageView.image = [UIImage imageNamed:@"img1.png"]; [self.view addSubview:imageView]; } int f = 25; for(int i = 0;i<f; i++){ UIImageView *imageView = [UIImageView new]; imageView.frame = CGRectMake(15+60*(i%5), 100+60*(i/5), 60, 60); imageView.image = [UIImage imageNamed:@"img1.png"]; [self.view addSubview:imageView]; } int rand = arc4random()%f; for(int i = 0; i<f; i++){ if(i == rand){ UIButton*button = [UIButton new]; button.frame = CGRectMake(15+60*(i%5), 100+60*(i/5), 60, 60); [button setImage:[UIImage imageNamed:@"img1.png"] forState:UIControlStateNormal]; [button addTarget:self action:@selector(buttonTapped) forControlEvents:UIControlEventTouchDown]; [self.view addSubview:button]; }else{ UIImageView *imageView = [UIImageView new]; imageView.frame = CGRectMake(15+60*(i%5), 100+60*(i/5), 60, 60); imageView.image = [UIImage imageNamed:@"img1.png"]; [self.view addSubview:imageView]; } } } - (IBAction)image:(id)sender { AudioServicesPlaySystemSound(sound_1); } -(void)buttonTapped{ } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end

  • EXECLの行を削除

    こんにちは 質問があります。 以下のコードのように、 テキストボックスに入力した行数の エクセルの行を削除したいのですが、 何も削除されません。 どなたか解決策を教えていただけないでしょうか よろしくお願いいたします。 import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.*; import org.apache.poi.hssf.usermodel.*; import org.apache.poi.poifs.filesystem.POIFSFileSystem; class testdel { public static void main(String[] args) { testdel2 test=new testdel2(); } } class testdel2 implements ActionListener { JButton button; JTextField text; testdel2() { JFrame frame=new JFrame(); JPanel panel=new JPanel(); button=new JButton("削除"); text=new JTextField(1); button.addActionListener(this); panel.add(text); panel.add(button); Container ct=frame.getContentPane(); ct.add(panel); frame.pack(); frame.setVisible(true); } public void actionPerformed(ActionEvent e) { if(e.getSource()==button) { int del_row=Integer.parseInt(text.getText()); Delete del=new Delete(del_row); } } } class Delete { Delete(int delrow) { try {System.out.println(delrow); FileInputStream fis = new FileInputStream("c:/sample.xls"); POIFSFileSystem fs = new POIFSFileSystem(fis); HSSFWorkbook wb1 = new HSSFWorkbook(fs); HSSFSheet sheet = wb1.getSheetAt(0); HSSFRow row=sheet.getRow(delrow); sheet.removeRow(row); System.exit(0); } catch(Exception e) { System.err.println(e.toString()); } } }

    • ベストアンサー
    • Java
  • Pythonでクエリパラメータを取得する際のエラー

    まずHTML側で href="http://root/page?ID={{id}}" として動的にクエリパラメータを含んだURLを設定します。 そのリンクにアクセスした際に、 サーバ側のmain.py内で def main(): application = webapp.WSGIApplication([('/page(.*)',PageHandler)],debug=True) util.run_wsgi_app(application) if__name__== '__main__': main() としてハンドラーを設定し、 class PageHandler(webapp.RequestHandler): def get(self): query = self.request.get('ID') parameta = {'pageID':query} fpath = os.path.join(os.path.dirname(__file__),'templates','page.html') html = template.render(fpath,parameta) self.response.headers['Content-Type'] = 'text/html' self.response.out.write(html) のquery = self.request.get('ID')でクエリパラメータを取得し、その値を渡しつつhtmlを書き出しさせています。 これを実際に動かすと TypeError: get() takes exactly 1 argument (2 given) というエラーが出て表示されないのですが、どこに問題があるんでしょうか? ちなみにGoogle App Engine上で実装しています。 

  • 新しいウィンドウで開きたい

    フレームで上下に分けたページで、 <input type="button" value="編集" onclick="parent.parent.location = '../page.php?id=1'"> このボタンを押すと、リンク先が親フレームに展開されますが、親フレームでなく、新しいウィンドウで開きたいと思います。 target="new"を指定しても駄目でした。「parent.parent.」をいじらなければ駄目でしょうか?