button test
Browse files
app.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
import discord
|
2 |
from discord.ui import Button
|
|
|
|
|
3 |
import gradio_client
|
4 |
from gradio_client import Client
|
5 |
import gradio as gr
|
@@ -49,26 +51,30 @@ class ButtonView(discord.ui.View):
|
|
49 |
for child in self.children:
|
50 |
child.disabled = True
|
51 |
self.stop()
|
|
|
|
|
|
|
|
|
52 |
|
53 |
@discord.ui.button(label='Image 1', style=discord.ButtonStyle.blurple)
|
54 |
async def image1_button(self, button: discord.ui.Button, interaction: discord.Interaction):
|
55 |
-
await self.
|
56 |
-
self.stop()
|
57 |
|
58 |
@discord.ui.button(label='Image 2', style=discord.ButtonStyle.blurple)
|
59 |
async def image2_button(self, button: discord.ui.Button, interaction: discord.Interaction):
|
60 |
-
await self.
|
61 |
-
self.stop()
|
62 |
|
63 |
@discord.ui.button(label='Image 3', style=discord.ButtonStyle.blurple)
|
64 |
async def image3_button(self, button: discord.ui.Button, interaction: discord.Interaction):
|
65 |
-
await self.
|
66 |
-
self.stop()
|
67 |
|
68 |
@discord.ui.button(label='Image 4', style=discord.ButtonStyle.blurple)
|
69 |
async def image4_button(self, button: discord.ui.Button, interaction: discord.Interaction):
|
70 |
-
await self.
|
71 |
-
self.stop()
|
72 |
#---------------------------------------------------------------------------------------------------------------------------------------------------
|
73 |
|
74 |
|
|
|
1 |
import discord
|
2 |
from discord.ui import Button
|
3 |
+
from discord.ext import commands #for buttons
|
4 |
+
|
5 |
import gradio_client
|
6 |
from gradio_client import Client
|
7 |
import gradio as gr
|
|
|
51 |
for child in self.children:
|
52 |
child.disabled = True
|
53 |
self.stop()
|
54 |
+
#-------------------------------------------
|
55 |
+
async def invoke_dfif2(self, image_path):
|
56 |
+
ctx = await self.ctx.bot.get_context(self.ctx)
|
57 |
+
await ctx.invoke(ctx.bot.get_command('dfif2'), image_path=image_path, stage_1_result_path=self.stage_1_result_path)
|
58 |
|
59 |
@discord.ui.button(label='Image 1', style=discord.ButtonStyle.blurple)
|
60 |
async def image1_button(self, button: discord.ui.Button, interaction: discord.Interaction):
|
61 |
+
await self.invoke_dfif2(self.image_paths[0])
|
62 |
+
self.stop()
|
63 |
|
64 |
@discord.ui.button(label='Image 2', style=discord.ButtonStyle.blurple)
|
65 |
async def image2_button(self, button: discord.ui.Button, interaction: discord.Interaction):
|
66 |
+
await self.invoke_dfif2(self.image_paths[1])
|
67 |
+
self.stop()
|
68 |
|
69 |
@discord.ui.button(label='Image 3', style=discord.ButtonStyle.blurple)
|
70 |
async def image3_button(self, button: discord.ui.Button, interaction: discord.Interaction):
|
71 |
+
await self.invoke_dfif2(self.image_paths[2])
|
72 |
+
self.stop()
|
73 |
|
74 |
@discord.ui.button(label='Image 4', style=discord.ButtonStyle.blurple)
|
75 |
async def image4_button(self, button: discord.ui.Button, interaction: discord.Interaction):
|
76 |
+
await self.invoke_dfif2(self.image_paths[3])
|
77 |
+
self.stop()
|
78 |
#---------------------------------------------------------------------------------------------------------------------------------------------------
|
79 |
|
80 |
|